Skip to content

Commit f7fbeed

Browse files
committed
adds global exception handler for application construction.
1 parent 0e4d433 commit f7fbeed

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Bootstrap.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,25 @@ function boot( string $ConfigPath ) : Application
3434
$Version = new Version();
3535
$Version->loadFromFile( "$BasePath/.version.json" );
3636

37-
return new Application( $Version->getAsString(), $Settings );
37+
try
38+
{
39+
$App = new Application( $Version->getAsString(), $Settings );
40+
}
41+
catch( \Exception $e )
42+
{
43+
echo Application::beautifyException( $e );
44+
exit( 1 );
45+
}
46+
47+
return $App;
3848
}
3949

4050
/**
4151
* Dispatches the current route mapped in the 'route' GET variable.
4252
*
4353
* @param Application $App
4454
*/
55+
4556
function dispatch( Application $App ) : void
4657
{
4758
$Route = Get::filterScalar( 'route' ) ?? "";

src/Mvc/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ public function clearExpiredCache(): int
480480
return 0;
481481
}
482482

483-
public function beautifyException( \Exception $e ): string
483+
public static function beautifyException( \Exception $e ): string
484484
{
485485
// this function should return a nicely formatted HTML representation of the exception
486486
$ExceptionType = get_class( $e );

0 commit comments

Comments
 (0)