FatalException and proper plugin detection

Using our own Exception makes it easier to differentiate fatal errors
from others in the log
This commit is contained in:
Andreas Gohr 2020-07-14 22:16:01 +02:00
parent cb4cefebb3
commit dbe0790d4c
2 changed files with 24 additions and 2 deletions

View File

@ -2,6 +2,13 @@
namespace dokuwiki;
use dokuwiki\Exception\FatalException;
/**
* Manage the global handling of errors and exceptions
*
* Developer may use this to log and display exceptions themselves
*/
class ErrorHandler
{
@ -88,7 +95,7 @@ EOT;
}
/**
* Last resort to handle fatal errors that still can't be cought
* Last resort to handle fatal errors that still can't be caught
*/
public static function fatalShutdown()
{
@ -106,7 +113,7 @@ EOT;
)
) {
self::fatalException(
new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'])
new FatalException($error['message'], 0, $error['type'], $error['file'], $error['line'])
);
}
}
@ -139,6 +146,10 @@ EOT;
*/
protected static function guessPlugin($e)
{
if (preg_match('/lib\/plugins\/(\w+)\//', str_replace('\\', '/', $e->getFile()), $match)) {
return $match[1];
}
foreach ($e->getTrace() as $line) {
if (
isset($line['class']) &&

View File

@ -0,0 +1,11 @@
<?php
namespace dokuwiki\Exception;
/**
* Fatal Errors are converted into this Exception in out Shutdown handler
*/
class FatalException extends \ErrorException
{
}