From 77fff9fde84f0ac55a7091e8d0ba8212e643685b Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 16 Aug 2019 12:13:47 +0200 Subject: [PATCH] #1607: Show more details when catching boot errors --- src/Http/Server.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Http/Server.php b/src/Http/Server.php index b48a5e531..21e5bcca7 100644 --- a/src/Http/Server.php +++ b/src/Http/Server.php @@ -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 << + $message
+ thrown in $file on line $line +ERROR; + } }