From 244d547ad2fafda37d97da0773c23323fec34c8a Mon Sep 17 00:00:00 2001 From: Obinna Elvis Okechukwu Date: Thu, 20 Nov 2025 11:28:09 +0100 Subject: [PATCH 1/3] refactor: update constructor type hints in ApplicationException class and remove render function --- src/Flame/Exception/ApplicationException.php | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/Flame/Exception/ApplicationException.php b/src/Flame/Exception/ApplicationException.php index 45b5e52a..f670b647 100644 --- a/src/Flame/Exception/ApplicationException.php +++ b/src/Flame/Exception/ApplicationException.php @@ -15,25 +15,8 @@ class ApplicationException extends Exception * @param int $code Error code. * @param Exception|null $previous Previous exception. */ - public function __construct($message = '', $code = 500, ?Exception $previous = null) + public function __construct(string $message = '', int $code = 500, ?Exception $previous = null) { parent::__construct($message, $code, $previous); } - - public function render(Request $request): Response - { - $message = $this->getMessage(); - - if (config('app.debug', false)) { - $message = sprintf('"%s" on line %s of %s', - $this->getMessage(), - $this->getLine(), - $this->getFile() - ); - - $message .= $this->getTraceAsString(); - } - - return response($message, $this->code); - } } From 09eab7e88da0ff797abc0e471fd96111c99fef5b Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Fri, 21 Nov 2025 01:19:33 +0000 Subject: [PATCH 2/3] minor fix --- src/Flame/Exception/ApplicationException.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Flame/Exception/ApplicationException.php b/src/Flame/Exception/ApplicationException.php index f670b647..ccf9dec0 100644 --- a/src/Flame/Exception/ApplicationException.php +++ b/src/Flame/Exception/ApplicationException.php @@ -5,8 +5,6 @@ namespace Igniter\Flame\Exception; use Exception; -use Illuminate\Http\Request; -use Illuminate\Http\Response; class ApplicationException extends Exception { From 50555984aaf3319cbc5959b9c52b78e1b9b14ef5 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Fri, 21 Nov 2025 11:39:34 +0000 Subject: [PATCH 3/3] minor fix --- .../Exception/ApplicationExceptionTest.php | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 tests/src/Flame/Exception/ApplicationExceptionTest.php diff --git a/tests/src/Flame/Exception/ApplicationExceptionTest.php b/tests/src/Flame/Exception/ApplicationExceptionTest.php deleted file mode 100644 index a9d4c8b9..00000000 --- a/tests/src/Flame/Exception/ApplicationExceptionTest.php +++ /dev/null @@ -1,33 +0,0 @@ - false]); - $exception = new ApplicationException('Default error message'); - $request = new Request; - $response = $exception->render($request); - expect($response)->toBeInstanceOf(Response::class) - ->and($response->getStatusCode())->toBe(500) - ->and($response->getContent())->toBe('Default error message'); -}); - -it('renders response with debug information when app debug is true', function() { - config(['app.debug' => true]); - $exception = new ApplicationException('Debug error message'); - $request = new Request; - $response = $exception->render($request); - expect($response)->toBeInstanceOf(Response::class) - ->and($response->getStatusCode())->toBe(500) - ->and($response->getContent())->toContain('Debug error message') - ->and($response->getContent())->toContain('on line') - ->and($response->getContent())->toContain('of') - ->and($response->getContent())->toContain($exception->getTraceAsString()); - config(['app.debug' => false]); -});