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.
32 lines
860 B
32 lines
860 B
3 years ago
|
using Microsoft.Extensions.Options;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
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;
|
||
|
}
|
||
|
}
|