Aspect-Injector driven Exception Logging and Asynchronous Code #185
-
Hi, I’ve grabbed and modernised the code from issue 77 to make it compatible with the lastest incarnation of Aspect-Injector, but any attempts I make to acquire and log the exception fail with further exceptions, usually within the Aspect itself where elements are incompatible with the output required. Does anyone using this extremely useful library have any ideas beyond what is mentioned in issue 77? I know the design of Aspect-Injector has moved a long way since issue 77, but the handling of async items seems to be either ignored or not discussed much. Any help would be greatfully received. Current code below, along with detail from a captured exception.
Logged output when using the “Universal” logger. A much simpler, non async compatible version works correctly but obviously only on synchronous functions.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @TheMouster , the development went as far as here https://github.com/pamidur/aspect-injector/blob/master/samples/src/Universal/Aspects/BaseUniversalWrapperAspect.cs or use an attribute from Aspects.Universal package like this [Injection(typeof(MethodWrapperAspect))]
class MyExceptionHandlingAttribute : Aspects.Universal.Attributes.BaseMethodPointsAspectAttribute
{
protected override T OnException<T>(AspectEventArgs eventArgs, Exception exception)
{
Log.Error("{type} threw a {exception} exception with {exceptionMessage}", eventArgs.Type, exception.GetType().Name, exception.Message);
return default(T);
}
} let me know if it works for you |
Beta Was this translation helpful? Give feedback.
Hi @TheMouster , the development went as far as here https://github.com/pamidur/aspect-injector/blob/master/samples/src/Universal/Aspects/BaseUniversalWrapperAspect.cs
you can either copy it.
or use an attribute from Aspects.Universal package
aspect-injector/samples/src/Universal/Attributes/BaseMethodPointsAspectAttribute.cs
Line 51 in e84f13f
like this