Question
How do you re-throw an exception in a `catch` block?
Asked by: USER1825
52 Viewed
52 Answers
Responsive Ad After Question
Answer (52)
You can re-throw an exception in a `catch` block using the `throw` keyword. This is useful when you want to log the exception or perform some cleanup, but still allow the exception to propagate up the call stack to be handled by a higher-level error handler. Example: `catch (Exception $e) { logError($e->getMessage()); throw $e; }`