-
-
Notifications
You must be signed in to change notification settings - Fork 430
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coroutines exception handler #1886
Conversation
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- Coroutines exception handler ([#1886](https://github.com/getsentry/sentry-java/pull/1886))If none of the above apply, you can opt out of this check by adding |
|
Would be good to add an example here: https://docs.sentry.io/platforms/java/enriching-events/scopes/#kotlin-coroutines |
| public class SentryCoroutineExceptionHandler(private val hub: IHub = HubAdapter.getInstance()) : AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler { | ||
| public constructor() : this(HubAdapter.getInstance()) | ||
|
|
||
| override fun handleException(context: CoroutineContext, exception: Throwable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should check if (context is SentryContext) and use the hub instance from there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HubAdapter always forwards to Sentry static class, it'd not make any difference.
| * Sentry exception handler element for [CoroutineExceptionHandler]. | ||
| */ | ||
| @ApiStatus.Experimental | ||
| public class SentryCoroutineExceptionHandler(private val hub: IHub = HubAdapter.getInstance()) : AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make it open for inheritance? If I have my custom exception handler I'd want to have mine on top of Sentry's, or we advise delegating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a good idea, other integrations had to make it open because of that.
|
Outdated, a new PR would make more sense. |
馃摐 Description
馃挕 Motivation and Context
Closes #1524
馃挌 How did you test it?
馃摑 Checklist
馃敭 Next steps