Navigation Menu

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

Define Error.Code as authoritative #25

Merged
merged 1 commit into from Jul 20, 2020
Merged

Conversation

matheusd
Copy link
Contributor

(Opening up as a PR directly with the suggested change to clarify this point for implementations and clients but happy to discuss if this isn't the actual intention of the Error Code/Message distinction.)

This makes it explicit that the Code attribute of the Error model is the
authoritative source of truth for the origin of the error, while the
error message is secondary.

It also makes it explicit that the same error code may present multiple
different messages so clients of Rosetta implementations should not rely
on them for error detection and Rosetta backends should make an effort
to present error codes in a granular enough level for clients.

@@ -25,13 +25,19 @@ properties:
description: |
Code is a network-specific error code. If desired, this code
can be equivalent to an HTTP status code.

This is considered the authoritative indicator of the cause
of the error.
type: integer
format: int32
minimum: 0
example: 12
message:
Copy link
Contributor

Choose a reason for hiding this comment

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

@matheusd We added the new Error.Details field in v1.4.0 to capture different messages related to the context of the error but expect Error.Message to stay the same for all errors of a particular code.

We do not yet assert that this is true in the rosetta-cli yet, but will begin to do so shortly now that we have the Error.Details field.

@patrick-ogrady
Copy link
Contributor

patrick-ogrady commented Jul 17, 2020

Thanks for posting this PR @matheusd (I think it may be the first external!) ... I clarified a point about Error.Message vs Error.Details and think the documentation around these models could definitely be improved to include this.

Would ❤️ if you repurposed this PR to improve the documentation on these Error fields!

@matheusd
Copy link
Contributor Author

Updated.

Given that the message has to be fixed, should they maybe be recommended to be code-like messages vs descriptive messages?

Stuff like "ErrBlockNotFound" vs "block not found"? Or do you feel this is an unnecessary distinction to make?

api.json Outdated Show resolved Hide resolved
api.json Outdated Show resolved Hide resolved
models/Error.yaml Outdated Show resolved Hide resolved
models/Error.yaml Outdated Show resolved Hide resolved
models/Error.yaml Outdated Show resolved Hide resolved
models/Error.yaml Outdated Show resolved Hide resolved
@patrick-ogrady
Copy link
Contributor

Thanks for writing these descriptions @matheusd! Some small nits around some extra trailing spaces but once those are fixed looks good.

Given that the message has to be fixed, should they maybe be recommended to be code-like messages vs descriptive messages?

Stuff like "ErrBlockNotFound" vs "block not found"? Or do you feel this is an unnecessary distinction to make?

That's a great question. I don't believe we need to restrict all messages to be code-like (descriptive messages may honestly make things more understandable). Consistency of message and code is the most important point here (which your changes already make clear).

@patrick-ogrady
Copy link
Contributor

(CircleCI didn't get kicked off so I had to close/open the PR)

Copy link
Contributor

@patrick-ogrady patrick-ogrady left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

This improves the description of the Error model by indicating that
error messages must be unique and cannot have contextual information.
@patrick-ogrady patrick-ogrady merged commit f14aa75 into coinbase:master Jul 20, 2020
@matheusd matheusd deleted the error branch July 20, 2020 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants