NancyFx/Nancy — pull request #1269 by rasmus-beck (2013-10-16 17:37:12+00:00)
Title: Added method to flatten exceptions before passing them on to the OnError pipeline hook

This is a proposed fix for issue #1232.

As described in issue #1232 the error pipeline hook does not unwrap the AggregateExceptions thrown from Tasks in the request handler.

One comment has to be made on this pull request. More than one exception can be nested inside AggregateExceptions, but the OnError pipeline hook only expects a single exception, so unless only one exception is actually nested inside the AggregateException we cannot fully unwrap it. In the case where more than one exception exists we have to return all of them in order not to swallow up any exception.

This is mentioned in a comment in the code as well, that should perhaps be deleted if the pull request is accepted.

Jon Skeet describes this issue in a short comment on Stack Overflow:
http://stackoverflow.com/questions/13570855/aggregateexception-what-does-aggregateexception-flatten-innerexception-repre