-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R4R: Improve SDK Error Messages & Allow Unicode #3604
Changes from all commits
5919627
95c4feb
6799621
b998830
9b51246
cb3643c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
package types | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/pkg/errors" | ||
cmn "github.com/tendermint/tendermint/libs/common" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
|
||
abci "github.com/tendermint/tendermint/abci/types" | ||
) | ||
|
||
|
@@ -246,19 +247,22 @@ func (err *sdkError) Code() CodeType { | |
|
||
// Implements ABCIError. | ||
func (err *sdkError) ABCILog() string { | ||
cdc := codec.New() | ||
errMsg := err.cmnError.Error() | ||
jsonErr := humanReadableError{ | ||
Codespace: err.codespace, | ||
Code: err.code, | ||
Message: errMsg, | ||
} | ||
bz, er := cdc.MarshalJSON(jsonErr) | ||
if er != nil { | ||
panic(er) | ||
|
||
var buff bytes.Buffer | ||
enc := json.NewEncoder(&buff) | ||
enc.SetEscapeHTML(false) | ||
|
||
if err := enc.Encode(jsonErr); err != nil { | ||
panic(errors.Wrap(err, "failed to encode ABCI error log")) | ||
} | ||
stringifiedJSON := string(bz) | ||
return stringifiedJSON | ||
|
||
return strings.TrimSpace(buff.String()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the @cosmos/cosmos-ui was hoping for something more like:
(from #3601) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this the expected response? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for following up @jbibla! Are you saying you wish it to be pretty JSON and indented? It already is JSON. |
||
} | ||
|
||
func (err *sdkError) Result() Result { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++