Skip to content

Commit 11fb7b6

Browse files
authored
Add detail to InvalidOperationException in Exception Handler Middleware (#22858)
1 parent fadca38 commit 11fb7b6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Middleware/Diagnostics/src/Resources.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
<value>Environment:</value>
249249
</data>
250250
<data name="ExceptionHandlerOptions_NotConfiguredCorrectly" xml:space="preserve">
251-
<value>An error occurred when configuring the exception handler middleware. Either the 'ExceptionHandlingPath' or the 'ExceptionHandler' option must be set in 'UseExceptionHandler()'.</value>
251+
<value>An error occurred when configuring the exception handler middleware. Either the 'ExceptionHandlingPath' or the 'ExceptionHandler' property must be set in 'UseExceptionHandler()'. Alternatively, set one of the aforementioned properties in 'Startup.ConfigureServices' as follows: 'services.Configure&lt;ExceptionHandlerOptions&gt;(options =&gt; { ... });'.</value>
252252
</data>
253253
<data name="ErrorPageHtml_NoRouteValues" xml:space="preserve">
254254
<value>No route values.</value>
@@ -280,4 +280,4 @@
280280
<data name="ErrorPageHtml_NameColumn" xml:space="preserve">
281281
<value>Name</value>
282282
</data>
283-
</root>
283+
</root>

src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,9 @@ public void UsingExceptionHandler_ThrowsAnException_WhenExceptionHandlingPathNot
406406
var exception = Assert.Throws<InvalidOperationException>(() => new TestServer(builder));
407407

408408
// Assert
409-
Assert.Equal($"An error occurred when configuring the exception handler middleware. " +
410-
$"Either the 'ExceptionHandlingPath' or the 'ExceptionHandler' option must be set in 'UseExceptionHandler()'.",
409+
Assert.Equal("An error occurred when configuring the exception handler middleware. " +
410+
"Either the 'ExceptionHandlingPath' or the 'ExceptionHandler' property must be set in 'UseExceptionHandler()'. " +
411+
"Alternatively, set one of the aforementioned properties in 'Startup.ConfigureServices' as follows: 'services.Configure<ExceptionHandlerOptions>(options => { ... });'.",
411412
exception.Message);
412413
}
413414
}

0 commit comments

Comments
 (0)