From 701a43317449f883b809622465ae2c041969fbe1 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 26 Feb 2026 22:58:28 +0800 Subject: [PATCH] Update exception handling in Handler and TestEmailController for improved error reporting --- app/Exceptions/Handler.php | 12 +++++++++--- app/Http/Controllers/TestEmailController.php | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index c7a75d3..fd662eb 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -22,8 +22,11 @@ class Handler extends ExceptionHandler { * @param \Exception $e * @return void */ - public function report(Exception $e) + public function report($e) { + if (!$e instanceof Exception) { + $e = new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + } return parent::report($e); } @@ -31,11 +34,14 @@ class Handler extends ExceptionHandler { * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request - * @param \Exception $e + * @param mixed $e * @return \Illuminate\Http\Response */ - public function render($request, Exception $e) + public function render($request, $e) { + if (!$e instanceof Exception) { + $e = new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + } return parent::render($request, $e); } diff --git a/app/Http/Controllers/TestEmailController.php b/app/Http/Controllers/TestEmailController.php index 0c4deee..49729d9 100644 --- a/app/Http/Controllers/TestEmailController.php +++ b/app/Http/Controllers/TestEmailController.php @@ -36,7 +36,7 @@ class TestEmailController extends Controller $status = 'success'; $message = 'Test email sent successfully to ' . $recipient . '.'; - } catch (\Exception $e) { + } catch (\Throwable $e) { $status = 'danger'; $message = 'Failed to send email: ' . $e->getMessage(); }