Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Let's say I have an exception in my network call during
SubscriptionTokenGetter.getSubscriptionToken
. I pass it tocb.Done
, but whenSubscriptionEventListener.onError
is called, all I see in the stack trace isIt says nothing about the reason why my call failed. I could've check if it's
SubscriptionTokenError
and getthrowable
, but this would require me to know about all the exceptions SDK could throw.That's why when you have an exception, and your create an other one with your details of how it happened, you should fill
cause
with the original exception.Here's how stacktrace looks like in this case:
I guess you could remove
throwable
property from such exceptions, as it's available in cause - but it's up to you, as I guess it may change API.Also, the difference between throwable and exception is that the former indicates that the current state of the application is faulty and cannot be recovered, so it must crash. For this reason nobody catches them - and catches Exception instead - it is better to get a crash in analytics to fix it than to ignore such an exception and get a malfunctioning application.
As your exceptions are not that critical, I would advise you to replace their superclass with exception - more for stability, since you're not really throwing them, so it shouldn't be a runtime problem unless someone would like to throw it at their own level to catch later.