From 2b9cec643431d0977b0461ea30c17921792c649f Mon Sep 17 00:00:00 2001 From: ipranjal Date: Thu, 3 Oct 2024 03:28:20 +0530 Subject: [PATCH] fix: send response if handled by handler --- src/functions.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/functions.php b/src/functions.php index 5f65c2a..112e119 100644 --- a/src/functions.php +++ b/src/functions.php @@ -1,7 +1,7 @@ registerHandler('exception', function($e){ +if(class_exists(\Scrawler\App::class) && function_exists('app')){ + app()->registerHandler('exception', function($e){ $whoops = new \Whoops\Run; $whoops->allowQuit(false); $whoops->writeToOutput(false); @@ -10,7 +10,11 @@ }else{ $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler); } - return $whoops->handleException($e); + $output = $whoops->handleException($e); + app()->response()->setStatusCode(500); + app()->response()->setContent($output); + app()->response()->send(); + }); }else{ $whoops = new \Whoops\Run;