Created
October 4, 2012 19:31
-
-
Save Rarst/3835861 to your computer and use it in GitHub Desktop.
Error handler with WordPress backtrace in message.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_error_handler( 'backtrace_error_handler', error_reporting() ); | |
function backtrace_error_handler( $errno, $errstr, $errfile, $errline, $errcontext ) { | |
// handle @ | |
if( 0 === error_reporting() ) | |
return false; | |
$message = $errstr . ' in ' . $errfile . ' on line ' . $errline . ', backtrace: ' . wp_debug_backtrace_summary( null, 1 ); | |
if( WP_DEBUG_DISPLAY || ini_get( 'display_errors' ) ) | |
echo '<br />' . $message . '<br />'; | |
if( WP_DEBUG_LOG || ini_get( 'log_errors' ) ) | |
error_log( $message ); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment