If you’ve written a .NET Lambda function which calls async code and returns either or , you’ve probably seen an which wraps the exception. Task Task<T> AggregateException real This example comes from the handler below which calls an asnyc method that always throws a . FormatException The can be unwrapped, though. When AWS added .NET Core 2.1 support to Lambda, they also added an undocumented feature toggle. The only real mention of it is by the AWS .NET team on . AggregateException Reddit When the environment variable is set to or , Lambda will call instead of using the property. UNWRAP_AGGREGATE_EXCEPTIONS 1 true GetAwaiter().GetResult() Result Note that this only works if your method returns or . Task Task<T> This causes the to be returned instead of an . first exception thrown AggregateException To avoid compatibility issues, this is via the environment variable. However, in the Reddit comment, . I think they’ll keep the toggle, though, because it can be useful. opt-in the team says they plan to make it the default behaviour in future versions The reason you get an is that a single can represent multiple parallel tasks, each of which can throw an exception. You’ll most often see this when using or . AggregateException Task Task.WaitAll Task.WhenAll This convoluted example runs three tasks in parallel, two of which throw an exception. Setting the environment variable gets us back to just the which was thrown first. In the future, you’ll need to toggle unwrapping exceptions off when you want to see every exception. UNWRAP_AGGREGATE_EXCEPTIONS FormatException For more like this, please follow me on and . Medium Twitter