-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: Parsed Err msgs #2119
R4R: Parsed Err msgs #2119
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2119 +/- ##
===========================================
+ Coverage 62.2% 63.83% +1.63%
===========================================
Files 115 113 -2
Lines 6874 6684 -190
===========================================
- Hits 4276 4267 -9
+ Misses 2314 2133 -181
Partials 284 284 |
types/errors.go
Outdated
Error: %#v | ||
=== /ABCI Log === | ||
`, err.codespace, err.code, err.ABCICode(), err.cmnError) | ||
parsedErrMsg := parseCmnError(err.cmnError.Error()) |
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.
Hmm do we want to change this upstream instead (or additionally)?
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.
@cwgoes you mean moving it to another util folder and export/import it ?
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.
I mean changing the cmn.Error
default format
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.
Given that cmn.Error is our own struct, we should totally change this there imo. We can merge this for now, and fix on a latrer tm release
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.
I can change it as well, but that would go on a separate PR for tendermint
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.
@ValarDragon just updated the parseCmnError
function so that once that we update cmn.Error.Error()
on Tm it doesn't break the SDK code
types/errors.go
Outdated
`, err.codespace, err.code, err.ABCICode(), err.cmnError) | ||
parsedErrMsg := parseCmnError(err.cmnError.Error()) | ||
jsonErr := newHumanReadableError(err.codespace, err.code, err.ABCICode(), parsedErrMsg) | ||
bz, er := json.Marshal(jsonErr) |
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.
Can we use the Amino JSON marshal here? Keeps things more consistent.
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.
Let's also use must marshal json
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.
There's no MustMarshalJSON
function @ValarDragon . I'll just use cdc.MarshalJSON
PENDING.md
Outdated
* [x/auth] Signature verification's gas cost now accounts for pubkey type. [#2046](https://github.com/tendermint/tendermint/pull/2046) | ||
|
||
* SDK | ||
* [tools] Make get_vendor_deps deletes `.vendor-new` directories, in case scratch files are present. | ||
* [types] \#2119 Parsed error messages and ABCI log errors to make them more human readable. |
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.
Would this be considered a breaking change, since it may break certain automation scripts?
types/errors.go
Outdated
Error: %#v | ||
=== /ABCI Log === | ||
`, err.codespace, err.code, err.ABCICode(), err.cmnError) | ||
parsedErrMsg := parseCmnError(err.cmnError.Error()) |
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.
Given that cmn.Error is our own struct, we should totally change this there imo. We can merge this for now, and fix on a latrer tm release
types/errors.go
Outdated
`, err.codespace, err.code, err.ABCICode(), err.cmnError) | ||
parsedErrMsg := parseCmnError(err.cmnError.Error()) | ||
jsonErr := newHumanReadableError(err.codespace, err.code, err.ABCICode(), parsedErrMsg) | ||
bz, er := json.Marshal(jsonErr) |
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.
Let's also use must marshal json
@@ -268,3 +275,25 @@ func (err *sdkError) QueryResult() abci.ResponseQuery { | |||
Log: err.ABCILog(), | |||
} | |||
} | |||
|
|||
func parseCmnError(err string) string { |
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.
This seems like a suboptimal way to parse this, we could have just had a better string method on cmn.error (For tendermint pr)
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.
Will open a separate PR for tendermint as well to change cmn.Error.Error()
types/errors.go
Outdated
Message string `json:"message"` | ||
} | ||
|
||
func newHumanReadableError(codespace CodespaceType, code CodeType, ABCICode ABCICodeType, msg string) HumanReadableError { |
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.
A new method seems unnecessary here.
types/errors.go
Outdated
} | ||
|
||
// nolint | ||
type HumanReadableError struct { |
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.
Let's not export this, it shouldn't be used anywhere else.
…edekunze/2044-JSON-err-msgs Merge develop
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.
utACK, let's remove parseCmnError
when we update upstream
Good work @fedekunze |
Thanks @faboweb ! 🙌 |
func parseCmnError(err string) string { | ||
if idx := strings.Index(err, "{"); idx != -1 { | ||
err = err[idx+1 : len(err)-1] | ||
} |
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.
This isn't a good way of doing this. This means when someone comes around to update the sdk to the next tm version, they won't see a break here, which means were more likely to have this legacy code laying around forever. It should have been something that will break, with a comment for how to upgrade imo.
@cwgoes when we have multiple people reviewing can we wait a bit between last update and merge? (Timezones meant I didn't see it between last update and merge)
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.
Generally I agree - @fedekunze didn't want to wait for the Tendermint PR, and this is blocking downstream.
This could indeed be written to break intentionally. I think tracking the necessary fix in an issue is fine too.
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.
Closes #2044 and luniehq/lunie#1131
New error formatting:
err.Error()
:err.ABCILog()
:docs/
)PENDING.md
with issue #Files changed
in the github PR explorerFor Admin Use: