Throwing multiple exceptions in .Net/C#

前端 未结 5 1434
渐次进展
渐次进展 2020-12-15 15:22

In an application I work on, any business logic error causes an exception to be thrown, and the calling code handles the exception. This pattern is used throughout the appl

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 16:13

    You could create a custom Exception that itself has a collection of Exceptions. Then, in your Catch block, just add it to that collection. At the end of your process, check if the Exception count is > 0, then throw your custom Exception.

提交回复
热议问题