Skip to content

Commit

Permalink
feat(exception): added aggregated exception from TPL
Browse files Browse the repository at this point in the history
  • Loading branch information
zhifenglee-aelf committed Oct 8, 2024
1 parent 06e9edf commit 9bfd008
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions AOPExceptionModule/ExceptionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ private class MethodInfo

public override void OnException(MethodExecutionArgs args)
{
// If it's an AggregateException, iterate through inner exceptions
if (args.Exception is AggregateException aggEx)
{
foreach (var innerEx in aggEx.InnerExceptions)
{
Console.WriteLine($"Inner exception: {innerEx.Message}");
HandleInnerException(innerEx, args);
}
}

else
{
HandleInnerException(args.Exception, args);
}
}

private void HandleInnerException(Exception exception, MethodExecutionArgs args)
{
if(!Exception.IsInstanceOfType(args.Exception))
{
return;
Expand Down

0 comments on commit 9bfd008

Please sign in to comment.