Title: try {} catch ( Exception $e ) in WordPress plugins
Last modified: March 10, 2017

---

# try {} catch ( Exception $e ) in WordPress plugins

 *  [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/try-catch-exception-e-in-wordpress-plugins/)
 * I’ve installed a plugin that is catching exceptions with try {} catch ( Exception
   $e ) {}.
 * Even if the debug log is turned on the exceptions are not being logged in debug.
   log. But New Relic is giving me tons of error warnings because of the exceptions
   thrown by the plugin.
 * Is using try {} catch ( Exception $e ) standard practice for WordPress plugins?
   How should exceptions be logged?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Lucas Karpiuk](https://wordpress.org/support/users/karpstrucking/)
 * (@karpstrucking)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/try-catch-exception-e-in-wordpress-plugins/#post-8870600)
 * Hey [@alekv](https://wordpress.org/support/users/alekv/), you should be able 
   to use PHP’s `error_log()` function for this.
 *  Thread Starter [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/try-catch-exception-e-in-wordpress-plugins/#post-8873350)
 * [@karpstrucking](https://wordpress.org/support/users/karpstrucking/)
 * I know that I can use `error_log()`
 * The question for me is rather if exceptions should or should not be logged in
   debug.log regardless if I use `error_log()` My opinion is they should be logged.
 *  [MrBrian](https://wordpress.org/support/users/mrbrian/)
 * (@mrbrian)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/try-catch-exception-e-in-wordpress-plugins/#post-8966561)
 * One thing to check is your PHP version.
    `try {} catch ( Exception $e )` will
   not be triggered in PHP 7.
 * Need to use `try {} catch ( Throwable $e )` instead
    -  This reply was modified 9 years, 2 months ago by [MrBrian](https://wordpress.org/support/users/mrbrian/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘try {} catch ( Exception $e ) in WordPress plugins’ is closed to new 
replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [MrBrian](https://wordpress.org/support/users/mrbrian/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/try-catch-exception-e-in-wordpress-plugins/#post-8966561)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
