Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the 5.x series of the Symfony components. #163

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor
composer.lock
composer.lock
/.idea/
8 changes: 4 additions & 4 deletions src/Exceptions/ConvertsExceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ trait ConvertsExceptions
/**
* Convert an exception to another exception
*
* @param \Exception $exception
* @param \Throwable $exception
* @param array $convert
* @return void
*/
protected function convert(Exception $exception, array $convert)
protected function convert(\Throwable $exception, array $convert)
{
foreach ($convert as $source => $target) {
if ($exception instanceof $source) {
Expand All @@ -60,7 +60,7 @@ protected function convert(Exception $exception, array $convert)
* @param \Exception $exception
* @return void
*/
protected function convertDefaultException(Exception $exception)
protected function convertDefaultException(\Throwable $exception)
{
$this->convert($exception, array_diff_key([
AuthenticationException::class => UnauthenticatedException::class,
Expand All @@ -87,4 +87,4 @@ protected function renderResponse(HttpException $exception): JsonResponse
->data($exception->data())
->respond($exception->statusCode(), $exception->getHeaders());
}
}
}
11 changes: 6 additions & 5 deletions src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Flugg\Responder\Exceptions\Http\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

/**
* An exception handler responsible for handling exceptions.
Expand All @@ -20,11 +19,13 @@ class Handler extends ExceptionHandler
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception|\Throwable $exception
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, $exception)
public function render($request, \Throwable $exception)
{
if ($request->wantsJson()) {
$this->convertDefaultException($exception);
Expand All @@ -36,4 +37,4 @@ public function render($request, $exception)

return parent::render($request, $exception);
}
}
}