Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jenky committed Aug 10, 2023
1 parent a20d8d5 commit 9ed8ca0
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/Exception/FormatsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];

Expand Down
30 changes: 0 additions & 30 deletions src/Exception/HasType.php

This file was deleted.

5 changes: 2 additions & 3 deletions tests/CustomExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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',
]);
}

Expand Down
2 changes: 0 additions & 2 deletions tests/Fixtures/OauthException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 9ed8ca0

Please sign in to comment.