-
Notifications
You must be signed in to change notification settings - Fork 698
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
js: Add JetStreamError with more API response details #1047
Conversation
3d28ca3
to
2540923
Compare
jsm.go
Outdated
Code() int | ||
ErrorCode() int | ||
Description() string | ||
Error() 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.
could add some other conditions to be able signal the client that something is Temporary()
here too, for example when there are transient errors such as JSClusterNotAvailable
Another idea is to make a more general |
I think I like the second approach (form |
Signed-off-by: Waldemar Quevedo <[email protected]>
Signed-off-by: Waldemar Quevedo <[email protected]>
Signed-off-by: Waldemar Quevedo <[email protected]>
… type Signed-off-by: Waldemar Quevedo <[email protected]>
Signed-off-by: Waldemar Quevedo <[email protected]>
Signed-off-by: Waldemar Quevedo <[email protected]>
|
return fmt.Sprintf("nats: %s", err.message) | ||
} | ||
|
||
func (err *jsError) Unwrap() 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.
More info about errors
package features of wrapping and Unwrap
can be found here:
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.
LGTM
Follow up from #1044
This adds a
JetStreamError
interface that exposes from details about the API response when it is one:To keep it backwards compatible and keep old checks working, instead of defining JetStream errors like this:
They can be defined like the following:
Signed-off-by: Waldemar Quevedo [email protected]