question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Most exceptions are logged as System.AggregateException

See original GitHub issue

Running with .NET 4.7.2, with heavy use of Parallel.ForEach. After moving to sentry-dotnet from Raven, most of our exceptions now show up in Sentry dashboard as “System.AggregateException: One or more errors occurred.”. Raven used to unpack those if there was just a single inner exception, which made the dashboard a lot more “glanceable”.

Now I understand this might be an explicit design choice not to unpack them: in this case, could you please provide a code sample how to preprocess them in the client code (I’m guessing somewhere with filters?)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
bruno-garciacommented, Sep 3, 2019

Although some of .NET’s API will wrap exceptions inAggregateException, simply because more than one exception could have happened at that point (i.e TPL), it’s also a valid scenario for a user to throw it’s own instance, with a meaningful message and location (stacktrace). Also, a catch block in between the throw and Sentry capturing it could have added useful stuff into Data. That would also be lost if we simply dropped the AggregateException

With that in mind, it was a design idea to not throw this information away automatically but perhaps shortsighted as for many usages of the TPL like yours this is likely noise only.

It’s a fair request to add the possibility to drop AggregateException altogether by default (on 2.0.0 which is breaking) although that will affect event grouping and could be a showstopper to many, I’m afraid.

Another option is to add an opt-in: UnwrapOnlyAggregateException or something with a much better name.

Code doing all that is here:

https://github.com/getsentry/sentry-dotnet/blob/c77736679b500f7cc7ad760d0274f2f703d7b34c/src/Sentry/Internal/MainExceptionProcessor.cs#L65-L102

In case you or someone else in the community like to help with a PR proposing a change. I’d be happy to review and discuss it further.

Until then:

The work around you’re looking for would look like this:

private class NoAggregateExceptionSentryEventProcessor : ISentryEventProcessor
{
    public SentryEvent Process(SentryEvent @event)
    {
        @event.SentryExceptions = @event.SentryExceptions
            .Where(e => e.Type != typeof(AggregateException).FullName).ToList();
        return @event;
    }
}
0reactions
mattjohnsonpintcommented, Mar 30, 2022

To summarize, we would like to add a client-side option to the SDK that will filter out aggregate exceptions, but would still keep all the inner exceptions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How to fix "'System.AggregateException' occurred in ...
Turn on Break on All Exceptions (Debug, Exceptions) and rerun the program. ... any exceptions (and logging) that are executed within a task....
Read more >
Debugging System.AggregateException - even in async code
As the name implies, AggregateException is used to batch one or more exceptions together in a single exception. In this post, I'll show...
Read more >
AggregateException.Flatten Method (System)
This method recursively flattens all instances of AggregateException exceptions that are inner exceptions of the current AggregateException instance. The inner ...
Read more >
One or more errors occurred. Stack Trace: Caught exception
Stack Trace: Caught exception: System.AggregateException Message: One or more errors occurred. at System.Threading.Tasks.Task.
Read more >
OCR Engine throws: RemoteException wrapping System. ...
When using an OCR engine activity, the following exception is thrown: RemoteException wrapping System.Exception: An unexpected error has ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found