This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Exceptions; | |
class RenderException extends \Exception | |
{ | |
public function report() | |
{ | |
// overwrite default report/log behavior | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Exceptions; | |
class Handler extends \Laravel\Lumen\Exceptions\Handler | |
{ | |
public function render($request, Throwable $exception) | |
{ | |
if ($exception instanceof CustomException) { | |
return response()->json(['error' => 'Oops!'], 400); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Exceptions\Handlers; | |
use Illuminate\Http\JsonResponse; | |
class AuthenticationException | |
{ | |
public function __invoke(\Exception $exception): ?JsonResponse | |
{ | |
return response()->json(['error' => 'Unauthorized: Access is denied due to invalid credentials.'], 401); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Exceptions; | |
use App\Exceptions\Handlers; | |
use Throwable; | |
use GuzzleHttp\Exception\RequestException; | |
use Illuminate\Auth\AuthenticationException; | |
use Illuminate\Database\QueryException; | |
use Illuminate\Http\JsonResponse; |