From 11fb7b67d1d8b0c84f6a786302872c34b8282aec Mon Sep 17 00:00:00 2001 From: Scott Addie <10702007+scottaddie@users.noreply.github.com> Date: Mon, 15 Jun 2020 13:31:23 -0500 Subject: [PATCH] Add detail to InvalidOperationException in Exception Handler Middleware (#22858) --- src/Middleware/Diagnostics/src/Resources.resx | 4 ++-- .../Diagnostics/test/UnitTests/ExceptionHandlerTest.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Middleware/Diagnostics/src/Resources.resx b/src/Middleware/Diagnostics/src/Resources.resx index 8cd9b2ea53..a45c81ad7e 100644 --- a/src/Middleware/Diagnostics/src/Resources.resx +++ b/src/Middleware/Diagnostics/src/Resources.resx @@ -248,7 +248,7 @@ Environment: - An error occurred when configuring the exception handler middleware. Either the 'ExceptionHandlingPath' or the 'ExceptionHandler' option must be set in 'UseExceptionHandler()'. + 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<ExceptionHandlerOptions>(options => { ... });'. No route values. @@ -280,4 +280,4 @@ Name - \ No newline at end of file + diff --git a/src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs b/src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs index d24965b760..da5c6c60d1 100644 --- a/src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs +++ b/src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs @@ -406,8 +406,9 @@ namespace Microsoft.AspNetCore.Diagnostics var exception = Assert.Throws(() => new TestServer(builder)); // Assert - Assert.Equal($"An error occurred when configuring the exception handler middleware. " + - $"Either the 'ExceptionHandlingPath' or the 'ExceptionHandler' option must be set in 'UseExceptionHandler()'.", + Assert.Equal("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(options => { ... });'.", exception.Message); } }