Skip to content

Commit 28e8ea3

Browse files
authored
Merge pull request #13 from Rod1Andrade/develop
Fix - Error handler now support Runtime Exceptions and Exceptions.
2 parents 3929bb7 + d9daf5a commit 28e8ea3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Helpers/ErrorHelper.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Rodri\SimpleRouter\Helpers;
55

6+
use Exception;
67
use Rodri\SimpleRouter\Response;
78
use RuntimeException;
89

@@ -14,20 +15,20 @@
1415
class ErrorHelper
1516
{
1617
/**
17-
* @param RuntimeException $runtimeException
18+
* @param RuntimeException|Exception $exception
1819
* @param bool $debugMode
1920
* @return Response
2021
*/
21-
public static function handle(RuntimeException $runtimeException, bool $debugMode = false): Response
22+
public static function handle(RuntimeException|Exception $exception, bool $debugMode = false): Response
2223
{
2324
if($debugMode)
2425
return new Response([
2526
'Mode' => 'Debug',
2627
'error' => 'ControllerMethodNotFoundException',
27-
'message' => $runtimeException->getMessage(),
28-
'line' => $runtimeException->getLine(),
29-
'file' => $runtimeException->getFile(),
30-
'trace' => $runtimeException->getTrace()
28+
'message' => $exception->getMessage(),
29+
'line' => $exception->getLine(),
30+
'file' => $exception->getFile(),
31+
'trace' => $exception->getTrace()
3132
], StatusCode::INTERNAL_SERVER_ERROR);
3233

3334
return new Response(Response::INVALID_RESPONSE, StatusCode::INTERNAL_SERVER_ERROR);

0 commit comments

Comments
 (0)