Questions tagged [aggregateexception]
61 questions
1
vote
3 answers
How to return AggregateException from async method
I got an async method working like an enhanced Task.WhenAll. It takes a bunch of tasks and returns when all are completed.
public async Task MyWhenAll(Task[] tasks) {
...
await Something();
...
// all tasks are completed
if…

adrianm
- 14,468
- 5
- 55
- 102
1
vote
2 answers
C++ approach to handling a collection of multiple exceptions?
In C++17, what is the proper pattern/approach to handling a collection of multiple exceptions?
Is there a C++ equivalent to C# AggregateException Class?
(I'm aware that exception as flow control is an anti-pattern.)

Eugene
- 10,957
- 20
- 69
- 97
1
vote
1 answer
Parallel.Foreach loop, inconsistent behavior with explicit throw statement
Created a simple program using Linqpad, where I am throwing an exception explicitly in the Parallel Foreach loop, which ideally shall be caught in the caller as Aggregate Exception, but when I explicitly throw the exception, it sometimes skip out…

Mrinal Kamboj
- 11,300
- 5
- 40
- 74
1
vote
1 answer
AggregateException Not Thrown in Task.Run()
I am trying to catch an AggregateException from a Task.Run() operation which intentionally fails, however an AggregateException is not thrown. Why?
public void EnterWaitingRoom(string val)
{
try
{
Task.Run(() =>…

Herb Ramos
- 23
- 4
1
vote
1 answer
Cancel Task and set status to "Cancelled"
I want a task to finish when the 50 Milliseconds are over. The status of the task should then be set to "Cancelled", otherwise to "RunToCompletion".
The task creation is here:
CancellationTokenSource cts = new…

Laurence
- 95
- 11
1
vote
1 answer
AggregateException during debugging forces restart of ForAll body
I'm experiencing really strange behavior, which I cannot neither understand nor explain. I was able to create a really simple sample to demonstrate that. That was reproduced on VS.Net 2013 & 2015 on different machines with several target .Net…

Lanorkin
- 7,310
- 2
- 42
- 60
1
vote
2 answers
C# Task.WaitAll() Cancelation with Error handling
I have a problem.
I try to run multiple long running tasks. If one fails I wanna cancel all other tasks and get the failure exception.
The example given below.
I wanna catch AggregateException with Exception thrown by
throw new…

Gintaras
- 15
- 2
- 10
1
vote
1 answer
Strange try/catch block behavior
I am working with Github API via Octokit.net. Now I am writing code that responsible for TwoFactorAuth. When I send request for token, if it is 2FA account, than I must get "TwoFactorRequiredException". I am trying to catch it, but insteand of it I…

Yura Babiy
- 515
- 7
- 22
1
vote
1 answer
Why isn't my try/catch block catching System.AggregateException?
I have some code that makes an asynchronous http call like so:
try
{
var myHttpClient = new HttpClient();
var uri = "http://myendpoint.com";
HttpResponseMessage response = client.GetAsync(uri).Result;
}
catch (Exception ex)
{
…

jkj2000
- 1,563
- 4
- 19
- 26
1
vote
0 answers
Json deserialize error AggregateException c#
I am getting an error trying to move a DataSourceResult from one web service to another... the client calls web service A which resides on our web server. We then make a call to web service B which resides on our db server. The intent is that web…

flagman
- 29
- 4
1
vote
2 answers
HttpClient async methods, aggregate exceptions
HttpClient async methods (e.g. PostAsync, GetAsync etc.), if an exception is thrown, returns an AggregateException. Now an aggregate exception can contain a list of inner exceptions. My question is can someone provide an example where one of the…

Mayoweezy
- 537
- 1
- 8
- 21
1
vote
0 answers
Unhandled AggregateException on Tasks Continuation thrown on another OS
I'm getting a strange behavior in a winForms application while testing to see how it responds on different OS.
The long running operation where the unhandled AggregateException is thrown ( when tested on a XP 32bit machine) is part of a WCF (using…

Pantelis
- 2,060
- 3
- 25
- 40
0
votes
1 answer
How to List<> of exceptions from ArgumentException and throw a AggregateException
private void AccountValidations(CreateAccountPayload payload) {
if (string.IsNullOrEmpty(payload.Note)) {
throw new ArgumentException($ "Note cannot be empty");
}
if (string.IsNullOrEmpty(payload.AccountName)) {
throw new…

mohan
- 1
- 2
0
votes
1 answer
OutOfMemoryException combined with another exception
I am looking into a memory problem and found this is the log today:
System.AggregateException: One or more errors occurred. ---> System.ArgumentException: Exception of type 'System.OutOfMemoryException' was thrown.Couldn't store <15.02.2017…

Halvard
- 3,891
- 6
- 39
- 51
0
votes
0 answers
Aggregate Exception not caught in xunit test cases
I'm querying a third-party SDK with a fully async-await method and SDK returns an AggregateException in a normal scenario. In AggregateException inner exception will be a type of ABCException.
But while mocking the same code in unit test cases with…

manish bhalodiya
- 1
- 2