-
Notifications
You must be signed in to change notification settings - Fork 9
Wrap provider errors with HTTP status code #30
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
Changes from 2 commits
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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package storage | ||
|
|
||
| import "fmt" | ||
|
|
||
| var _ error = (*ErrorWithStatusCode)(nil) | ||
|
|
||
| type ErrorWithStatusCode struct { | ||
| Err error | ||
| StatusCode int | ||
| } | ||
|
|
||
| func (e *ErrorWithStatusCode) Error() string { | ||
| return fmt.Sprintf("Err: %s, Status Code: %d", e.Err, e.StatusCode) | ||
|
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. nit: error stings are usually not capitalized |
||
| } | ||
|
|
||
| func (e *ErrorWithStatusCode) UnWrap() error { | ||
|
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. should this be 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. maybe we could add assertion on the wrapped error in tests as well |
||
| return e.Err | ||
| } | ||
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.
license header missing