Unhandled Exception in WithScope
See original GitHub issueWhile I might have incorrectly used WithScope
this lead to my entire web app crashing on Azure every time it tried to call Twilio. They are having a rough day: https://status.twilio.com/
Environment
How do you use Sentry? Sentry SaaS (sentry.io)
Which SDK and version? Sentry.AspNetCore @ 3.0.5
Steps to Reproduce
var response = await _httpClient.PostAsync("Messages.json", new FormUrlEncodedContent(content));
if (response.IsSuccessStatusCode == false) {
SentrySdk.WithScope(async scope => {
scope.SetExtra("error", await response.Content.ReadAsStringAsync());
response.EnsureSuccessStatusCode();
});
}
Expected Result
It would log an exception in Sentry with the response captured.
Actual Result
It crashed my entire web app instance.
Unhandled exception. System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (INTERNAL SERVER ERROR).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at LoadOne.Infrastructure.Services.SMS.<>c__DisplayClass2_0.<<SendMessage>b__0>d.MoveNext() in C:\projects\webapp\src\LoadOne.Infrastructure\Services\ISMS.cs:line 51
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
AWS Node Lambda unhandled exception thrown in Sentry. ...
When running the lambda I get a failure from AWS but the unhandled exception is not captured in Sentry. If I move the...
Read more >Troubleshooting for Next.js - Browser JavaScript
When you include and configure Sentry, our JavaScript SDK automatically attaches global handlers to capture uncaught exceptions and unhandled promise rejections ...
Read more >java - Get rid of "Caught an unhandled exception:" in ...
The message is a warning because you are not handling the exception so add an exception handler for the exception to get rid...
Read more >sentry_flutter | Flutter Package
Sentry SDK for Flutter. This package aims to support different Flutter targets by relying on the many platforms supported by Sentry with native...
Read more >How to use the @sentry/node.withScope function in @ ...
To help you get started, we've selected a few @sentry/node.withScope examples, based on popular ways it is used in public projects.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh I would have thought that goes into the
UnobservedTaskException
but there’s a good explanation here why this is.This was using .NET Core 3.1. Here is an example: