getMessage()); $msg = 'An unforeseen error has occured. This is most likely a bug somewhere.'; $logged = self::logException($e) ? 'More info has been written to the DokuWiki _error.log' : $e->getFile() . ':' . $e->getLine(); echo << $title

$title

$msg

$logged

EOT; } /** * Convenience method to display an error message for the given Exception * * @param \Throwable $e * @param string $intro */ public static function showExceptionMsg($e, $intro = 'Error!') { $msg = $intro . get_class($e) . ': ' . $e->getMessage(); self::logException($e); msg(hsc($msg), -1); } /** * Default error handler to convert old school warnings, notices, etc to exceptions * * You should not need to call this directly! * * @param int $errno * @param string $errstr * @param string $errfile * @param int $errline * @return bool * @throws \ErrorException */ public static function errorConverter($errno, $errstr, $errfile, $errline) { if (!(error_reporting() & $errno)) { // This error code is not included in error_reporting, so let it fall // through to the standard PHP error handler return false; } throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); } /** * Log the given exception to the error log * * @param \Throwable $e * @return bool false if the logging failed */ public static function logException($e) { global $conf; $log = join("\t", [gmdate('c'), get_class($e), $e->getFile() . ':' . $e->getLine(), $e->getMessage()]) . "\n"; return io_saveFile($conf['cachedir'] . '/_error.log', $log, true); } }