Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Merge dd5dd34 into e9d32af
Browse files Browse the repository at this point in the history
  • Loading branch information
ls-renaud-tilte committed Sep 21, 2020
2 parents e9d32af + dd5dd34 commit c560569
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -2,9 +2,9 @@ language: php
sudo: false

php:
- 7.1
- 7.2
- 7.3
- 7.4

before_script:
- composer self-update
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -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": {
Expand Down
14 changes: 7 additions & 7 deletions src/NewRelicExceptionHandler.php
Expand Up @@ -2,7 +2,7 @@

namespace Nord\Lumen\NewRelic;

use Exception;
use Throwable;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

Expand Down Expand Up @@ -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);
Expand All @@ -50,7 +50,7 @@ public function report(Exception $e)
/**
* @inheritdoc
*/
public function render($request, Exception $e)
public function render($request, Throwable $e)
{

}
Expand All @@ -59,15 +59,15 @@ public function render($request, Exception $e)
/**
* @inheritdoc
*/
public function renderForConsole($output, Exception $e)
public function renderForConsole($output, Throwable $e)
{

}

/**
* @inheritdoc
*/
public function shouldReport(Exception $e)
public function shouldReport(Throwable $e)
{
foreach ($this->ignoredExceptions as $type) {
if ($e instanceof $type) {
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions tests/NewRelicServiceProviderTest.php
Expand Up @@ -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
Expand Down Expand Up @@ -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());
}
}

0 comments on commit c560569

Please sign in to comment.