Skip to content
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

Merged
merged 6 commits into from
Feb 11, 2019

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Feb 11, 2019

  • Improve funds-based SDK error messages
  • Allow unicode to not be escaped in JSON (e.g. so error messages will actually display <)

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@alexanderbez alexanderbez changed the title WIP: Improve SDK Error Messages & Allow Unicode R4R: Improve SDK Error Messages & Allow Unicode Feb 11, 2019
enc.SetEscapeHTML(false)

if err := enc.Encode(jsonErr); err != nil {
panic(errors.Wrap(err, "failed to encode ABCI error log"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

@faboweb
Copy link
Contributor

faboweb commented Feb 11, 2019

Will this return an actual JSON instead of {message: SOME_ERROR_STRING}?

@alexanderbez
Copy link
Contributor Author

alexanderbez commented Feb 11, 2019

@faboweb I don't follow. This improves the error messages and displays unicode (in the JSON response).

e.g.

{"codespace":"sdk","code":5,"message":"insufficient funds to pay for fees; 50atom < 100atom"}

Copy link
Member

@jackzampolin jackzampolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way better error messages here

@alexanderbez
Copy link
Contributor Author

@faboweb Ohhh, I see what you mean, no this doesn't solve that. In fact #3601 is a duplicate of #2953 I believe.

@codecov
Copy link

codecov bot commented Feb 11, 2019

Codecov Report

Merging #3604 into develop will decrease coverage by 0.01%.
The diff coverage is 45.45%.

@@             Coverage Diff             @@
##           develop    #3604      +/-   ##
===========================================
- Coverage    61.46%   61.44%   -0.02%     
===========================================
  Files          186      186              
  Lines        13981    13990       +9     
===========================================
+ Hits          8593     8596       +3     
- Misses        4841     4847       +6     
  Partials       547      547

@jackzampolin jackzampolin merged commit 9c23fe6 into develop Feb 11, 2019
@jackzampolin jackzampolin deleted the bez/3601-improve-funds-err-msgs branch February 11, 2019 23:12
stringifiedJSON := string(bz)
return stringifiedJSON

return strings.TrimSpace(buff.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the @cosmos/cosmos-ui was hoping for something more like:

{
  "codespace": "sdk",
  "code": 10,
  "message": "You are trying to send more stake than you own."
}

(from #3601)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the expected response?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants