Moved files into respective folders for better orgranization
This commit is contained in:
parent
c46615dc53
commit
9044aeff47
|
|
@ -22,7 +22,7 @@ namespace ErrorHandlerSample
|
||||||
await context.Response.WriteAsync("<html><body>\r\n");
|
await context.Response.WriteAsync("<html><body>\r\n");
|
||||||
await context.Response.WriteAsync("We're sorry, we encountered an un-expected issue with your application.<br>\r\n");
|
await context.Response.WriteAsync("We're sorry, we encountered an un-expected issue with your application.<br>\r\n");
|
||||||
|
|
||||||
var error = context.Features.Get<IErrorHandlerFeature>();
|
var error = context.Features.Get<IExceptionHandlerFeature>();
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
// This error would not normally be exposed to the client
|
// This error would not normally be exposed to the client
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Diagnostics
|
namespace Microsoft.AspNet.Diagnostics
|
||||||
{
|
{
|
||||||
public interface IErrorHandlerFeature
|
public interface IExceptionHandlerFeature
|
||||||
{
|
{
|
||||||
Exception Error { get; }
|
Exception Error { get; }
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
{
|
{
|
||||||
ErrorHandlingPath = new PathString(errorHandlingPath)
|
ErrorHandlingPath = new PathString(errorHandlingPath)
|
||||||
};
|
};
|
||||||
return app.UseMiddleware<ErrorHandlerMiddleware>(options);
|
return app.UseMiddleware<ExceptionHandlerMiddleware>(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -76,7 +76,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
{
|
{
|
||||||
ErrorHandler = errorPipeline
|
ErrorHandler = errorPipeline
|
||||||
};
|
};
|
||||||
return app.UseMiddleware<ErrorHandlerMiddleware>(options);
|
return app.UseMiddleware<ExceptionHandlerMiddleware>(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Diagnostics
|
namespace Microsoft.AspNet.Diagnostics
|
||||||
{
|
{
|
||||||
public class ErrorHandlerFeature : IErrorHandlerFeature
|
public class ExceptionHandlerFeature : IExceptionHandlerFeature
|
||||||
{
|
{
|
||||||
public Exception Error { get; set; }
|
public Exception Error { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -11,18 +11,18 @@ using Microsoft.Net.Http.Headers;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Diagnostics
|
namespace Microsoft.AspNet.Diagnostics
|
||||||
{
|
{
|
||||||
public class ErrorHandlerMiddleware
|
public class ExceptionHandlerMiddleware
|
||||||
{
|
{
|
||||||
private readonly RequestDelegate _next;
|
private readonly RequestDelegate _next;
|
||||||
private readonly ErrorHandlerOptions _options;
|
private readonly ErrorHandlerOptions _options;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly Func<object, Task> _clearCacheHeadersDelegate;
|
private readonly Func<object, Task> _clearCacheHeadersDelegate;
|
||||||
|
|
||||||
public ErrorHandlerMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, ErrorHandlerOptions options)
|
public ExceptionHandlerMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, ErrorHandlerOptions options)
|
||||||
{
|
{
|
||||||
_next = next;
|
_next = next;
|
||||||
_options = options;
|
_options = options;
|
||||||
_logger = loggerFactory.CreateLogger<ErrorHandlerMiddleware>();
|
_logger = loggerFactory.CreateLogger<ExceptionHandlerMiddleware>();
|
||||||
if (_options.ErrorHandler == null)
|
if (_options.ErrorHandler == null)
|
||||||
{
|
{
|
||||||
_options.ErrorHandler = _next;
|
_options.ErrorHandler = _next;
|
||||||
|
|
@ -53,11 +53,11 @@ namespace Microsoft.AspNet.Diagnostics
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var errorHandlerFeature = new ErrorHandlerFeature()
|
var errorHandlerFeature = new ExceptionHandlerFeature()
|
||||||
{
|
{
|
||||||
Error = ex,
|
Error = ex,
|
||||||
};
|
};
|
||||||
context.Features.Set<IErrorHandlerFeature>(errorHandlerFeature);
|
context.Features.Set<IExceptionHandlerFeature>(errorHandlerFeature);
|
||||||
context.Response.StatusCode = 500;
|
context.Response.StatusCode = 500;
|
||||||
context.Response.Headers.Clear();
|
context.Response.Headers.Clear();
|
||||||
context.Response.OnStarting(_clearCacheHeadersDelegate, context.Response);
|
context.Response.OnStarting(_clearCacheHeadersDelegate, context.Response);
|
||||||
Loading…
Reference in New Issue