Rethrowing an exception - CSharp Custom Type

CSharp examples for Custom Type:Exception

Introduction

You can capture and rethrow an exception as follows:

try {  ...  }                                                                                
catch (Exception ex)
{
  // Log error
  ...
  throw;          // Rethrow same exception
}

Rethrowing in this manner lets you log an error without swallowing it.


Related Tutorials