diff --git a/src/Exception/FormatsException.php b/src/Exception/FormatsException.php index 37fca5d..7d0a114 100644 --- a/src/Exception/FormatsException.php +++ b/src/Exception/FormatsException.php @@ -71,7 +71,7 @@ protected function prepareReplacements(Throwable &$exception, int $statusCode = $replacements = [ ':message' => $e->getMessage() ?: $e->getStatusText(), ':status_code' => $e->getStatusCode(), - ':type' => method_exists($exception, 'getType') ? $exception->getType() : class_basename($e->getClass()), + ':type' => class_basename($e->getClass()), ':code' => $e->getCode(), ]; diff --git a/src/Exception/HasType.php b/src/Exception/HasType.php deleted file mode 100644 index d61d638..0000000 --- a/src/Exception/HasType.php +++ /dev/null @@ -1,30 +0,0 @@ -type = $type; - } - - /** - * Get exception type. - */ - public function getType(): string - { - return $this->type; - } -} diff --git a/tests/CustomExceptionTest.php b/tests/CustomExceptionTest.php index ac378b4..7a647d8 100644 --- a/tests/CustomExceptionTest.php +++ b/tests/CustomExceptionTest.php @@ -30,8 +30,7 @@ protected function loadRoutes() Route::prefix('api/v1') ->group(function () { Route::get('exception-type', function () { - throw (new OauthException(400, 'The grant type is not available for your client!')) - ->setType('oauth'); + throw (new OauthException(400, 'The grant type is not available for your client!')); }); Route::get('exception-callback', function () { @@ -47,7 +46,7 @@ public function test_exception_has_type() ->assertJson([ 'message' => 'The grant type is not available for your client!', 'status_code' => 400, - 'type' => 'oauth', + 'type' => 'OauthException', ]); } diff --git a/tests/Fixtures/OauthException.php b/tests/Fixtures/OauthException.php index a03ef09..9027d41 100644 --- a/tests/Fixtures/OauthException.php +++ b/tests/Fixtures/OauthException.php @@ -2,10 +2,8 @@ namespace Jenky\Hades\Tests\Fixtures; -use Jenky\Hades\Exception\HasType; use Symfony\Component\HttpKernel\Exception\HttpException; class OauthException extends HttpException { - use HasType; }