Throwing an AggregateException in my own code

Are you talking about something like this?

var exceptions = new List<Exception>();
foreach (var item in items) {
    try {
        DoSomething(item);

    } catch (Exception ex) {
        exceptions.Add(ex);
    }
}

if (exceptions.Count > 0)
    throw new AggregateException(
        "Encountered errors while trying to do something.",
        exceptions
    );

Seems like the most logical way to me.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)