-
Notifications
You must be signed in to change notification settings - Fork 22
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
Observations (Catch listener handler exceptions separately from IO exceptions) #51
Comments
Oh wow, I can't believe I hadn't linked it in the README. I'll fix that right away. As for your second point, I am unsure what you mean. Is it for example if you throw a Runtime exception in a listener? |
Actually I just looked incorrectly. It more looks like error message Example:
Stacktrace/error message:
|
Right, right, now I follow. So, the issue here is that messages are handled asynchronously on a separate thread, and uncaught exceptions that reach the "top" of that separate thread has to be handled somewhere. If I don't catch that exception, the entire thread risk halting, which would cause it to not process any more IRC messages. Just logging if it gets that far is the least disruptive approach I can think of. I guess an alternative would be to allow the user to supply a custom handler for uncaught exceptions, that could be an alternative approach to just catching the uncaught exception and log to stderr (as a side note, you can supply a custom logging function so it doesn't just print to stderr). But it isn't possible to throw the exception out of the asynchronous handler, since they aren't part of the linear program flow. |
Another possibility is to catch exceptions when handling listeners separately so that exception doesn't propagate this high at "handling input". At that point input has been handled, My main point here is, that exceptions at IO level, message parsing, listener should be at different levels. Then the client won't receive message about IO/message parser when it's at listener level. Otherwise I understand exception handling and I think it's fine like this imho :) |
Ah, alright. Thanks for explaining how you view of it. I misunderstood you at first. And you got a really good point. I never thought of that, to be honest. I should definitely catch exceptions at different levels at you say, so we can distinguish between OP level and listener level exceptions. I'll rename this issue to something that explains the idea, and keep it in mind when I do some further updates! :) |
Some observations from using this simple and cool library for a few hours:
The text was updated successfully, but these errors were encountered: