Rethrow the current exception
To rethrow the current exception, use the throwstatement without passing it an exception.
The following code snippet demonstrates this technique:
The following code snippet demonstrates this technique:
try { // Do something dangerous. } catch (Exception) { // Log the error. // Re-throw the exception. throw; }Contrast this code with the following version:
try { // Do something dangerous. } catch (Exception ex) { // Log the error. // Re-throw the exception. throw ex; }
둘의 차이는?
댓글
댓글 쓰기