#1607: Show more details when catching boot errors

This commit is contained in:
Franz Liedke 2019-08-16 12:13:47 +02:00
parent 430ddefb42
commit 3feca515c3

View File

@ -56,7 +56,24 @@ class Server
try {
return $this->site->bootApp();
} catch (Throwable $e) {
exit('Error booting Flarum: '.$e->getMessage());
exit($this->formatBootException($e));
}
}
/**
* Display the most relevant information about an early exception.
*/
private function formatBootException(Throwable $error): string
{
$message = $error->getMessage();
$file = $error->getFile();
$line = $error->getLine();
$type = get_class($error);
return <<<ERROR
Flarum encountered a boot error ($type)<br />
<b>$message</b><br />
thrown in <b>$file</b> on line <b>$line</b>
ERROR;
}
}