diff --git a/src/RouterException.php b/src/RouterException.php index 920931d..2966aad 100755 --- a/src/RouterException.php +++ b/src/RouterException.php @@ -37,6 +37,13 @@ public function __construct(string $message = "", int $code = 0, ?Throwable $pre */ public function exception_handler(Throwable $exception): void { + if (Rudra::config()->get("environment") === "development") { + $debugbar = Rudra::get("debugbar"); + if ($debugbar && $debugbar->hasCollector('exceptions')) { + $debugbar['exceptions']->addException($exception); + } + } + Redirect::responseCode($exception->getCode()); Router::directCall(Rudra::config()->get("http.errors")[$exception->getCode()]); } diff --git a/src/helpers.php b/src/helpers.php index 163420b..bec47b6 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -12,8 +12,8 @@ use Rudra\Exceptions\RouterException; if (!function_exists('abort')) { - function abort(int $code): void + function abort(int $code, string $message = ''): void { - throw new RouterException($code); + throw new RouterException($message ?: "HTTP Error {$code}", $code); } }