• 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)
  • Hey @alekv, you should be able to use PHP’s error_log() function for this.

    Thread Starter alekv

    (@alekv)

    @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.

    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 7 years, 8 months ago by MrBrian.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘try {} catch ( Exception $e ) in WordPress plugins’ is closed to new replies.