dotnetcore/AspectCore-Framework

asp.net core环境下抛出异常堆栈信息不全

wuuer opened this issue · 5 comments

wuuer commented

controller引用了一个使用了AOP的类,类中某方法抛异常出异常时(如空指针异常),异常堆栈信息最后只定位到controller调用这个类的这个方法的位置,没有定位到这个方法里发生异常的位置

wuuer commented

这个问题不好解决吗?

emmm 是作者最近有点懒。。抽空看看

同遇到此问题,请问有更新计划吗?

public Exception Wrap(AspectContext aspectContext, Exception exception)
{
if (!_configuration.ThrowAspectException)
{
return exception;
}

public AspectConfiguration()
{
ThrowAspectException = false;
ValidationHandlers = new AspectValidationHandlerCollection().AddDefault(this);
Interceptors = new InterceptorCollection();
NonAspectPredicates = new NonAspectPredicateCollection().AddDefault();
}

var configurationService = services.LastOrDefault(x => x.ServiceType == typeof(IAspectConfiguration) && x.ImplementationInstance != null);
var configuration = (IAspectConfiguration) configurationService?.ImplementationInstance ?? new AspectConfiguration();
configure?.Invoke(configuration);
if (configurationService == null)
{
services.AddSingleton(configuration);
}

不知为何ThrowAspectException 默认是为false。

单独注册一下设置为true就行了。

services.AddSingleton<IAspectConfiguration>(new AspectConfiguration { ThrowAspectException = true });

近期会处理这些问题 。谢谢理解