-
Notifications
You must be signed in to change notification settings - Fork 91
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
dex: general purpose go 1.13 error type #484
Conversation
type testErr string | ||
|
||
func (te testErr) Error() string { | ||
return string(te) | ||
} | ||
|
||
const ( | ||
err0 = testErr("other error") | ||
err1 = ErrorKind("error 1") | ||
err2 = ErrorKind("error 2") | ||
) |
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.
Illustrating the purpose of ErrorKind
(to avoid the boiler plate of creating a type that defines Error() string
), while allowing a const
, which errors.New
prevents.
Ready for review, in concept at least, since the new types are not being applied repo-wide. |
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 this be used to clean up https://github.com/decred/dcrdex/blob/master/dex/msgjson/types.go ? Can this also help errors used with the rpc calls, or are int codes %100 necessary?
If the only thing to wrap is a description, I think |
No, I think the msgjson package has different requirements, so I wouldn't change that. |
Resolving #483
Based on the
DetailedError
typedcrdex/server/db/driver/pg/errors.go
Lines 14 to 38 in ecbeacc