You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
793 B
28 lines
793 B
using Microsoft.Extensions.Options; |
|
using Volo.Abp.DependencyInjection; |
|
|
|
namespace Sanhe.Abp.Wrapper; |
|
|
|
public class ExceptionWrapHandlerFactory : IExceptionWrapHandlerFactory, ITransientDependency |
|
{ |
|
private readonly AbpWrapperOptions _options; |
|
|
|
public ExceptionWrapHandlerFactory(IOptions<AbpWrapperOptions> options) |
|
{ |
|
_options = options.Value; |
|
} |
|
|
|
public IExceptionWrapHandler CreateFor(ExceptionWrapContext context) |
|
{ |
|
var exceptionType = context.Exception.GetType(); |
|
var handler = _options.GetHandler(exceptionType); |
|
if (handler == null) |
|
{ |
|
handler = new DefaultExceptionWrapHandler(); |
|
_options.AddHandler(exceptionType, handler); |
|
return handler; |
|
} |
|
|
|
return handler; |
|
} |
|
}
|
|
|