@@ -102,13 +102,8 @@ private static void SetExceptionHandlerFeatures(ErrorContext errorContext)
102
102
/// </summary>
103
103
/// <param name="context"></param>
104
104
/// <returns></returns>
105
- [ DebuggerDisableUserUnhandledExceptions ]
106
105
public async Task Invoke ( HttpContext context )
107
106
{
108
- // We want to avoid treating exceptions as user-unhandled if an exception filter like the DatabaseDeveloperPageExceptionFilter
109
- // handles the exception rather than letting it flow to the default DisplayException method. This is because we don't want to stop the
110
- // debugger if the developer shouldn't be handling the exception and instead just needs to do something like click a link to run a
111
- // database migration.
112
107
try
113
108
{
114
109
await _next ( context ) ;
@@ -127,11 +122,6 @@ public async Task Invoke(HttpContext context)
127
122
context . Response . StatusCode = StatusCodes . Status499ClientClosedRequest ;
128
123
}
129
124
130
- // Generally speaking, we do not expect application code to handle things like IOExceptions during a request
131
- // body read due to a client disconnect. But aborted requests should be rare in development, and developers
132
- // might be surprised if an IOException propagating through their code was not considered user-unhandled.
133
- // That said, if developers complain, we consider removing the following line.
134
- Debugger . BreakForUserUnhandledException ( ex ) ;
135
125
return ;
136
126
}
137
127
@@ -141,8 +131,6 @@ public async Task Invoke(HttpContext context)
141
131
{
142
132
_logger . ResponseStartedErrorPageMiddleware ( ) ;
143
133
_metrics . RequestException ( exceptionName , ExceptionResult . Skipped , handler : null ) ;
144
-
145
- // Rethrowing informs the debugger that this exception should be considered user-unhandled.
146
134
throw ;
147
135
}
148
136
@@ -173,16 +161,11 @@ public async Task Invoke(HttpContext context)
173
161
}
174
162
catch ( Exception ex2 )
175
163
{
176
- // It might make sense to call BreakForUserUnhandledException for ex2 after we do the same for the original exception.
177
- // But for now, considering the rarity of user-defined IDeveloperPageExceptionFilters, we're not for simplicity.
178
-
179
164
// If there's a Exception while generating the error page, re-throw the original exception.
180
165
_logger . DisplayErrorPageException ( ex2 ) ;
181
166
}
182
167
183
168
_metrics . RequestException ( exceptionName , ExceptionResult . Unhandled , handler : null ) ;
184
-
185
- // Rethrowing informs the debugger that this exception should be considered user-unhandled.
186
169
throw ;
187
170
}
188
171
@@ -195,9 +178,6 @@ public async Task Invoke(HttpContext context)
195
178
// Assumes the response headers have not been sent. If they have, still attempt to write to the body.
196
179
private Task DisplayException ( ErrorContext errorContext )
197
180
{
198
- // We need to inform the debugger that this exception should be considered user-unhandled since it wasn't fully handled by an exception filter.
199
- Debugger . BreakForUserUnhandledException ( errorContext . Exception ) ;
200
-
201
181
var httpContext = errorContext . HttpContext ;
202
182
var headers = httpContext . Request . GetTypedHeaders ( ) ;
203
183
var acceptHeader = headers . Accept ;
0 commit comments