* @author Stephan Schmidt * @author Sebastian 'The Argh' Mordziol * @version 0.1 * @license LGPL * @link http://www.php-tools.net */ class patErrorHandlerDebug { /** * niceDie - outputs a nicely formatted version of the traditional die() * * @static * @access public * @param string $error The error message to display */ public function niceDie($error) { echo '
critical Error encountered [patDebugErrorHandler]
Error details  : 
';
                                        print_r( $error );
        echo    '                    
'; exit(); } /** * error handler that outputs nice debugging HTML * * Displays: * - Error level * - Error Message * - Error info * - Error file * - Error line * - plus the call stack that lead to the error * * The output has been inspired by Derick Rethan's xDebug. * * @author Stephan Schmidt * @access public * @static * @param object error object * @return object error object * @todo console output (no HTML) */ public function schstDebug($error) { echo '
'; printf( '%s: %s (Userinfo: %s) in %s on line %s
', patErrorManager::translateErrorLevel( $error->getLevel() ), $error->getMessage(), $error->getInfo(), $error->getFile(), $error->getLine() ); $backtrace = $error->getBacktrace(); if (is_array($backtrace)) { $j = 1; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; for( $i = count( $backtrace )-1; $i >= 0 ; $i-- ) { echo ' '; echo " "; if( isset( $backtrace[$i]['class'] ) ) { echo " "; } else { echo " "; } if( isset( $backtrace[$i]['file'] ) ) { echo " "; } else { echo " "; } echo ' '; $j++; } echo '
Call stack
#FunctionLocation
{$j}{$backtrace[$i]['class']}{$backtrace[$i]['type']}{$backtrace[$i]['function']}(){$backtrace[$i]['function']}(){$backtrace[$i]['file']}:{$backtrace[$i]['line']} 
'; } echo '
'; $level = $error->getLevel(); if( $level != E_ERROR ) return $error; exit(); } /** * Error handler that outputs pretty debugging HTML * * Displays: * - Error level * - Error Message * - Error info * - Error file * - Error line * - plus the call stack that lead to the error * * The output has been inspired by Schst's debug, updated for a * designer's eye. * * @author Sebastian Mordziol * @access public * @static * @param object error object * @return object error object */ public function arghDebug($error) { $GLOBALS['_pat_errorsCounter'] = $GLOBALS['_pat_errorsCounter'] + 1; $prefix = 'arghDebug'; $errorColors = array( E_NOTICE => 'F6F6F6', E_WARNING => 'FEFCF3', E_ERROR => 'FFE3CA', ); // display the styles definition, but only once if( !$GLOBALS['_pat_errorStylesPrinted'] ) { echo ''; echo ''; $GLOBALS['_pat_errorStylesPrinted'] = true; } echo '
'; printf( '
%s: %s in %s on line %s
', patErrorManager::translateErrorLevel( $error->getLevel() ), $error->getMessage(), $error->getFile(), $error->getLine() ); echo '
Details: '; $details = $error->getInfo(); if( !empty( $details ) ) { echo $details; } else { echo 'no additional info available'; } echo '
'; echo ''; $backtrace = $error->getBacktrace(); if( is_array( $backtrace ) ) { $j = 1; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; for( $i = count( $backtrace )-1; $i >= 0 ; $i-- ) { echo ' '; echo ' '; if( isset( $backtrace[$i]['class'] ) ) { echo ' '; } else { echo ' '; } if( isset( $backtrace[$i]['file'] ) ) { echo ' '; } else { echo ' '; } echo ' '; $j++; } echo '
#FunctionLocation
'.$j.''.$backtrace[$i]['class'].$backtrace[$i]['type'].$backtrace[$i]['function'].'()'.$backtrace[$i]['function'].'()'.$backtrace[$i]['file'].':'.$backtrace[$i]['line'].' 
'; } echo '
'; $level = $error->getLevel(); if( $level != E_ERROR ) return $error; exit(); } } ?>