-
Notifications
You must be signed in to change notification settings - Fork 158
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
Generic exception thrown from NatsJetStream.publishAsyncInternal() #858
Comments
Also see #768 |
I did see the other issue, my understanding was that it talked about
The other methods in the client expose the error types directly, so this one stands out - Especially because there is no technical reason for wrapping the exceptions an extra time. |
@chrispoulsen Yes, I just linked them, they are similar. I haven't had time to fully grok this, but when I do, I will have to make sure any change is backaward compatible, meaning we might have to live with this until a major version change. |
@cpoulsen-dezide I'm thinking about how to fix this in a backward compatible manner. I could add a connection option that is essentially "better error messages" and behave differently if the user sets this option. What do you think? |
If flipping that option on would result in a more correct API - That in turn would make my code have a shape that translates better with the next major (breaking) update of the client, then I would use it. From an API perspective it might be a bit dangerous to start locking down the shape of next API version- I guess it depends on how mature everything is in the client API and when an update is expected. This issue is not about a deal-breaker - it was more about it triggering my OCD as everything is usable, it is just not as elegant as it could be. |
Async errors are too generic
NatsJetStream:168
throws aRuntimeException
in case an error happens. As this happens inside a future that RTE gets wrapped in aCompletionException
before it re-emerges from theCompletableFuture
as an error.In my case I do the
publishAsync()
and want to ensure that the returned value / exception are of my types:The mapper code looks like this currently:
It is the
CompletionException.getCause().getCause()
in the top, that seems out of order.If the following patch is applied, the real exceptions are only wrapped in
CompletionException
(once) likeCompletableFuture
s are supposed to work:In Java v9+ the "throws" line would probably be replaced with the following, to better express the intent:
Basically it feels like the
CompletionException( new RuntimeException( IOException | JetStreamApiException ) )
structure is wrong.The text was updated successfully, but these errors were encountered: