Best practices for catching and re-throwing .NET exceptions

前端 未结 11 1481
野的像风
野的像风 2020-11-22 07:15

What are the best practices to consider when catching exceptions and re-throwing them? I want to make sure that the Exception object\'s InnerException

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 08:11

    You may also use:

    try
    {
    // Dangerous code
    }
    finally
    {
    // clean up, or do nothing
    }
    

    And any exceptions thrown will bubble up to the next level that handles them.

提交回复
热议问题