Deals with PHP 5 throwing an exception.
public paintException ( Exception $exception ) | ||
$exception | Exception | The actual exception thrown. |
/** * Called when a caught exception needs to be output. */ function paintException($exception) { // Explicitly call grandparent, not parent::paintException. SimpleScorer::paintException($exception); $message = 'Unexpected exception of type [' . get_class($exception) . '] with message [' . $exception->getMessage() . '] in [' . $exception->getFile() . ' line ' . $exception->getLine() . ']'; $stacktrace = null; if (method_exists($exception, 'getTrace')) { $stacktrace = $exception->getTrace(); } $this->_paintPassFail('exception', $message, $stacktrace); }
/** * Called when a caught exception needs to be output. */ function paintException($exception) { // Explicitly call grandparent, not parent::paintException. SimpleScorer::paintException($exception); if (is_a($exception, 'moodle_exception') && !get_string_manager()->string_exists($exception->errorcode, $exception->module)) { $exceptionmessage = 'Exception with missing language string {' . $exception->errorcode . '} from language file {' . $exception->module . '}'; if (!empty($exception->a)) { if (is_string($exception->a)) { $data = $exception->a; } else { $data = array(); foreach ((array) $exception->a as $name => $value) { $data[] = $name . ' => [' . $value . ']'; } $data = implode(', ', $data); } $exceptionmessage .= ' with data {' . $data . '}'; } } else { $exceptionmessage = $exception->getMessage(); } $message = 'Unexpected exception of type [' . get_class($exception) . '] with message [' . $exceptionmessage . '] in [' . $exception->getFile() . ' line ' . $exception->getLine() . ']'; $debuginfo = null; if (!empty($exception->debuginfo)) { $debuginfo = $exception->debuginfo; } $this->_paintPassFail('exception', $message, $exception->getTrace(), $debuginfo); }