diff --git a/.travis.yml b/.travis.yml index 326ea1d..e27fb65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,9 @@ language: php sudo: false php: - - 7.1 - 7.2 - 7.3 + - 7.4 before_script: - composer self-update diff --git a/composer.json b/composer.json index 5ce00ff..9781855 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,13 @@ } ], "require": { - "php": "^7.1", + "php": "^7.2", "intouch/newrelic": "^1.0", - "illuminate/support": "^5.5|^6.0", + "illuminate/support": "^5.5 | ^6.0 | ^7.0 | ^8.0", "nordsoftware/lumen-chained-exception-handler": "^1.0" }, "require-dev": { - "laravel/lumen-framework": "^5.5|^6.0", + "laravel/lumen-framework": "^5.5|^6.0|^7.0|^8.0", "phpunit/phpunit": "^7.5" }, "autoload": { diff --git a/src/NewRelicExceptionHandler.php b/src/NewRelicExceptionHandler.php index e833a7f..c7d52ad 100644 --- a/src/NewRelicExceptionHandler.php +++ b/src/NewRelicExceptionHandler.php @@ -2,7 +2,7 @@ namespace Nord\Lumen\NewRelic; -use Exception; +use Throwable; use Illuminate\Contracts\Debug\ExceptionHandler; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -39,7 +39,7 @@ public function __construct($ignoredExceptions = false) /** * @inheritdoc */ - public function report(Exception $e) + public function report(Throwable $e) { if ($this->shouldReport($e)) { $this->logException($e); @@ -50,7 +50,7 @@ public function report(Exception $e) /** * @inheritdoc */ - public function render($request, Exception $e) + public function render($request, Throwable $e) { } @@ -59,7 +59,7 @@ public function render($request, Exception $e) /** * @inheritdoc */ - public function renderForConsole($output, Exception $e) + public function renderForConsole($output, Throwable $e) { } @@ -67,7 +67,7 @@ public function renderForConsole($output, Exception $e) /** * @inheritdoc */ - public function shouldReport(Exception $e) + public function shouldReport(Throwable $e) { foreach ($this->ignoredExceptions as $type) { if ($e instanceof $type) { @@ -80,9 +80,9 @@ public function shouldReport(Exception $e) /** * Logs the exception to New Relic (if the extension is loaded) * - * @param Exception $e + * @param Throwable $e */ - protected function logException(Exception $e) + protected function logException(Throwable $e) { if (extension_loaded('newrelic')) { newrelic_notice_error($e->getMessage(), $e); diff --git a/tests/NewRelicServiceProviderTest.php b/tests/NewRelicServiceProviderTest.php index 31d391c..13eeb6b 100644 --- a/tests/NewRelicServiceProviderTest.php +++ b/tests/NewRelicServiceProviderTest.php @@ -8,6 +8,7 @@ use Nord\Lumen\NewRelic\NewRelicExceptionHandler; use Nord\Lumen\NewRelic\NewRelicServiceProvider; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpKernel\Exception\HttpException; /** * Class NewRelicServiceProviderTest @@ -46,13 +47,13 @@ public function testRegisterExceptionHandler() // Define a route that throws an exception $app->router->get('/', function() { - throw new \Exception(); + throw new HttpException(550); }); // Verify that the error handling doesn't silenty fail (which would happen if the exception handler isn't // registered correctly) $response = $app->handle(Request::create('/', 'GET')); - $this->assertEquals(500, $response->getStatusCode()); + $this->assertEquals(550, $response->getStatusCode()); $this->assertContains('Whoops, looks like something went wrong', $response->getContent()); } }