You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ProjectTemplates/ReferenceProject/Middleware/ExceptionMiddleware.cs
+6-5Lines changed: 6 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -10,13 +10,14 @@
10
10
namespaceReferenceProject.Middleware
11
11
{
12
12
/// <summary>
13
-
/// Middleware to handle unhandled exceptions.
14
-
/// It separates exceptions based on their type and returns different status codes and answers based on it, instead of 500 Internal Server Error code in all cases
13
+
/// Middleware to handle exceptions.
14
+
/// It separates exceptions based on their type and returns different status codes and answers based on it, instead of 500 Internal Server Error code in all cases.
15
+
/// In addition, it writes them in the log.
15
16
/// </summary>
16
17
/// <remarks>
17
18
/// There is another way to do this - an exception filter.
18
19
/// However, a middleware is a preferred way to achieve this according to the official documentation.
19
-
/// To learn more see https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-2.2#exception-filters
20
+
/// To learn more see https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-2.1#exception-filters
20
21
/// </remarks>
21
22
publicclassExceptionMiddleware
22
23
{
@@ -41,7 +42,7 @@ public async Task InvokeAsync(HttpContext context)
41
42
catch(Exceptionex)
42
43
{
43
44
// If context.Response.HasStarted == true, then we can't write to the response stream anymore. So we have to restore the body.
0 commit comments