Skip to content

Commit fbf32f0

Browse files
authored
add 500 error
1 parent da16691 commit fbf32f0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

index.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
use Monster\App\Models\Env;
34
use Monster\App\Route;
45

@@ -70,10 +71,20 @@
7071
// PHP error handling
7172
$config = new Env('.env');
7273
$debug = $config->get("APP_DEBUG");
74+
7375
if ($debug == "true") {
7476
$whoops = new \Whoops\Run;
7577
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
7678
$whoops->register();
79+
} else {
80+
set_error_handler(function () {
81+
http_response_code(500);
82+
include_once("routes/errors/500.php");
83+
});
84+
set_exception_handler(function () {
85+
http_response_code(500);
86+
include_once("routes/errors/500.php");
87+
});
7788
}
7889

7990
// Load application helpers
@@ -83,4 +94,4 @@
8394
require 'routes/web.php';
8495

8596
// Run the application
86-
Route::run();
97+
Route::run();

0 commit comments

Comments
 (0)