Skip to content

Commit b87b99a

Browse files
committed
Adjust comments in ExceptionMiddleware
1 parent 8ad6bfe commit b87b99a

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

ProjectTemplates/ReferenceProject/Middleware/ExceptionMiddleware.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
namespace ReferenceProject.Middleware
1111
{
1212
/// <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.
1516
/// </summary>
1617
/// <remarks>
1718
/// There is another way to do this - an exception filter.
1819
/// 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
2021
/// </remarks>
2122
public class ExceptionMiddleware
2223
{
@@ -41,7 +42,7 @@ public async Task InvokeAsync(HttpContext context)
4142
catch (Exception ex)
4243
{
4344
// If context.Response.HasStarted == true, then we can't write to the response stream anymore. So we have to restore the body.
44-
// If we were don't do that we get an exception.
45+
// If we don't do that we get an exception.
4546
context.Response.Body = body;
4647
await HandleExceptionAsync(context, ex);
4748
}
@@ -54,7 +55,7 @@ async Task HandleExceptionAsync(HttpContext context, Exception ex)
5455
context.Response.ContentType = "application/json";
5556
context.Response.StatusCode = statusCode;
5657

57-
// We can decide what the status code should be
58+
// We can decide what the status code should return
5859
if (ex is KeyNotFoundException)
5960
{
6061
context.Response.StatusCode = StatusCodes.Status404NotFound;

0 commit comments

Comments
 (0)