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

Catch errors in Dispatchers and log #1200

Merged
merged 1 commit into from
Aug 12, 2024
Merged

Conversation

MauriceVanVeen
Copy link
Member

Resolves #1198

We could handle the Error in the ErrorListener just like the Exception is handled.
But, an Error is likely to not be recoverable so probably stopping the dispatcher is the way to go? Just need to log that it happened.

@MauriceVanVeen MauriceVanVeen requested a review from scottf August 12, 2024 16:03
Copy link
Contributor

@scottf scottf left a comment

Choose a reason for hiding this comment

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

LGTM

} catch (Error err) {
// Make sure we log, so we don't silently exit our loop.
// https://github.com/nats-io/nats.java/issues/1198
err.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

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

what about

connection.processException(new Exception(err));

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm leaning more toward logging and failing, than still processing the error and continuing on.
I'm thinking an Error indicates something that's not recoverable, versus an Exception being something that's just unexpected or can be retried.

In the case that the Error is not recoverable, there is probably not much we can do to keep running anyway. Might as well log and quit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to indeed process as exception and continue.

@MauriceVanVeen MauriceVanVeen changed the title Catch errors in Dispatchers to log before quiting Catch errors in Dispatchers and log Aug 12, 2024
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
@MauriceVanVeen MauriceVanVeen force-pushed the fix/catch-error-in-dispatchers branch from 85a9dd8 to 0714961 Compare August 12, 2024 19:35
Copy link
Contributor

@scottf scottf left a comment

Choose a reason for hiding this comment

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

LGTM

@scottf scottf merged commit 9ca3a92 into main Aug 12, 2024
4 checks passed
@scottf scottf deleted the fix/catch-error-in-dispatchers branch August 12, 2024 19:49
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.

Throwing Error in onMessage callback in Dispatcher silently breaks
2 participants