Skip to content

Commit b12a64d

Browse files
authored
Merge pull request #172 from ruelluna/master
Update documentation on Exception Handling Laravel 8 Compatibility
2 parents 5079a88 + a8a35c2 commit b12a64d

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

readme.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -547,30 +547,29 @@ You can catch these exceptions inside `app/Exceptions/Handler.php` file and do w
547547
* Render an exception into an HTTP response.
548548
*
549549
* @param \Illuminate\Http\Request $request
550-
* @param \Exception $exception
550+
* @param \Throwable $e
551551
* @return \Illuminate\Http\Response
552552
*/
553-
public function render($request, Exception $exception)
554-
{
555-
556-
$userLevelCheck = $exception instanceof \jeremykenedy\LaravelRoles\App\Exceptions\RoleDeniedException ||
557-
$exception instanceof \jeremykenedy\LaravelRoles\App\Exceptions\PermissionDeniedException ||
558-
$exception instanceof \jeremykenedy\LaravelRoles\App\Exceptions\LevelDeniedException;
559-
560-
if ($userLevelCheck) {
561-
562-
if ($request->expectsJson()) {
563-
return Response::json(array(
564-
'error' => 403,
565-
'message' => 'Unauthorized.'
566-
), 403);
567-
}
568-
569-
abort(403);
570-
}
571-
572-
return parent::render($request, $exception);
573-
}
553+
public function render($request, Throwable $e)
554+
{
555+
$userLevelCheck = $e instanceof \jeremykenedy\LaravelRoles\App\Exceptions\RoleDeniedException ||
556+
$e instanceof \jeremykenedy\LaravelRoles\App\Exceptions\PermissionDeniedException ||
557+
$e instanceof \jeremykenedy\LaravelRoles\App\Exceptions\LevelDeniedException;
558+
559+
if ($userLevelCheck) {
560+
561+
if ($request->expectsJson()) {
562+
return Response::json(array(
563+
'error' => 403,
564+
'message' => 'Unauthorized.'
565+
), 403);
566+
}
567+
568+
abort(403);
569+
}
570+
571+
return parent::render($request, $e);
572+
}
574573
```
575574

576575
---

0 commit comments

Comments
 (0)