Skip to content

Comments

[IMPROVED] Expose JetStream API error codes to user for better error handling#1977

Open
edandavi wants to merge 1 commit intonats-io:mainfrom
edandavi:js-api-errors
Open

[IMPROVED] Expose JetStream API error codes to user for better error handling#1977
edandavi wants to merge 1 commit intonats-io:mainfrom
edandavi:js-api-errors

Conversation

@edandavi
Copy link

Following this discussion with @wallyqs
this change allows the user to handle all the various jetstream API errors the server may return
like so:

if errors.Is(err, jetstream.JSErrCode..) {
  // do something
}

…andling

Signed-off-by: Edan David <edandavi@gmail.com>
@piotrpio
Copy link
Collaborator

piotrpio commented Jan 8, 2026

Sorry to be late here - I think this is a good idea, although I'm wondering if it wouldn't be convenient to have those error codes generated from server (as the server has all error codes listed in json anyway): https://github.com/nats-io/nats-server/blob/main/server/errors.json

We could have a template just for generating error codes and we would not have to worry about manually keeping the list up to date.

@edandavi would you be up to doing that?

@edandavi
Copy link
Author

edandavi commented Jan 8, 2026

Hi @piotrpio,

Sure, I can do it,
but how would we sync the JSON file from the server repo to the client repo?

A possible solution could be to separate the errors JSON into a common mini-repository that would hold the errors, but that would require changes in the server repo too.
Or to manually copy it and then generate, which kind of beats the purpose here, I guess…

@wallyqs wallyqs changed the title [IMPROVED] Expose Jetsream API error codes to user for better error handling [IMPROVED] Expose JetStream API error codes to user for better error handling Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants