#1607: Show more details when catching boot errors

This commit is contained in:
Franz Liedke 2019-08-16 12:13:47 +02:00 committed by Daniël Klabbers
parent 5d768db6d2
commit c5e3e26d07

View File

@ -54,7 +54,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;
}
}