/** * Catches errors that are not caught by the error handler, such as E_PARSE. * * @uses Eight_Exception::handle() * @return void */ public static function shutdown_handler() { if (Eight_Exception_PHP::$enabled and $error = error_get_last() and error_reporting() & $error['type']) { // Fake an exception for nice debugging Eight_Exception::handle(new Eight_Exception_PHP($error['type'], $error['message'], $error['file'], $error['line'])); } }
/** * Create a new PHP error exception. * * @return void */ public function __construct($code, $error, $file, $line, $context = NULL) { parent::__construct($error); // Set the error code, file, line, and context manually $this->code = $code; $this->file = $file; $this->line = $line; }
/** * Set internal properties. * * @param string URI of page * @param string custom error template */ public function __construct($page = NULL) { if ($page === NULL) { // Use the complete URI $page = Router::$complete_uri; } parent::__construct(strtr('The page you requested, %page%, could not be found.', array('%page%' => $page))); }
/** * Sets exception message and debug info. * * @param string message * @param mixed debug info * @return void */ public function __construct($message, $debug = nil) { // Failure message parent::__construct("UnitTest Exception", (string) $message); // Extra user-defined debug info $this->debug = $debug; // Overwrite failure location $trace = $this->getTrace(); $this->file = $trace[0]['file']; $this->line = $trace[0]['line']; }
" class="collapsed"> <table cellspacing="0"> <?php foreach ($GLOBALS[$var] as $key => $value) { ?> <tr> <td> <code> <?php echo $key; ?> </code> </td> <td> <pre><?php echo Eight_Exception::dump($value); ?> </pre> </td> </tr> <?php } ?> </table> </div> <?php } ?> </div> </div> </div>
/** * Set exception title and message. * * @param string exception title string * @param string exception message string * @param string custom error template */ public function __construct($title, $message, array $variables = NULL) { parent::__construct($message, $variables); // Code is the error title $this->code = $title; }
/** * Returns a stacktrace in the form of a string */ public static function trace_string($trace) { $string = ""; // Setup the stack trace $string .= Eight_Exception::trace_string_line("Stack trace:"); $string .= Eight_Exception::trace_string_line(""); $x = 0; foreach (Eight_Exception::trace($trace) as $i => $step) { $msg_line = "#" . str_pad($x, 2, "0", STR_PAD_LEFT) . " "; if ($step['file']) { $source_id = $error_id . 'source' . $i; $msg_line .= Eight_Exception::debug_path($step['file']) . '(' . $step['line'] . "): "; } else { $msg_line .= "{" . __('PHP internal call') . "}: "; } $msg_line .= $step['function'] . '('; $print_able_args = array(); if ($step['args']) { $args_id = $error_id . 'args' . $i; foreach ($step['args'] as $arg) { $arg_name = ""; if (is_object($arg)) { $arg_name = get_class($arg); } else { if (is_array($arg)) { $arg_name = "Array(" . count($arg) . ")"; } else { if (is_null($arg)) { $arg_name = "NULL"; } else { if (is_string($arg)) { $arg_name = $arg; } else { $arg_name = strval($arg); } } } } $arg_name = preg_replace("#\\s+#", " ", $arg_name); $print_able_args[] = str::limit_chars($arg_name, 50, ""); } } $msg_line .= implode(", ", $print_able_args); $msg_line .= ")"; $string .= Eight_Exception::trace_string_line($msg_line); $x++; } return $string; }
/** * Cleans up the PHP environment. Disables error/exception handling and the * auto-loading method and closes the output buffer. * * This method does not need to be called during normal system execution, * however in some advanced situations it can be helpful. */ public static function cleanup() { static $run; // Only run this function once if ($run === TRUE) { return; } $run = TRUE; // Using Eight Errors? Disable them since we're finished. if (Eight::$errors === TRUE) { Eight_Exception::disable(); Eight_Exception_PHP::disable(); } spl_autoload_unregister(array('Eight', 'auto_load')); Eight::close_buffers(); }
add_line("Line: " . $line); add_break(); add_line("Message:"); foreach (explode("\n", $message) as $msg_line) { add_line(trim($msg_line)); } add_break(); if (Eight_Exception::$trace_output) { add_line("Stack trace:"); add_line(""); $x = 0; foreach (Eight_Exception::trace($trace) as $i => $step) { $msg_line = "#" . str_pad($x, 2, "0", STR_PAD_LEFT) . " "; if ($step['file']) { $source_id = $error_id . 'source' . $i; $msg_line .= Eight_Exception::debug_path($step['file']) . '(' . $step['line'] . "): "; } else { $msg_line .= "{" . __('PHP internal call') . "}: "; } $msg_line .= $step['function'] . '('; $print_able_args = array(); if ($step['args']) { $args_id = $error_id . 'args' . $i; foreach ($step['args'] as $arg) { $arg_name = ""; if (is_object($arg)) { $arg_name = get_class($arg); } else { if (is_array($arg)) { $arg_name = "Array(" . count($arg) . ")"; } else {
public function __construct($message, $variables = NULL, $code = 0) { parent::__construct($message, $variables, $code); }
/** * Magic method, returns the output of [View::render]. * * @return string * @uses View::render */ public function __toString() { try { return $this->render(); } catch (Exception $e) { // Display the exception message Eight_Exception::handle($e); return ''; } }