I'm using prepareJsonResponse()
from Illuminate\Foundation\Exceptions\Handler
to handle exceptions, and I'm calling it from my App\Exceptions\Handler.php:render()
.
return $this->prepareJsonResponse($request, $e);
As you can see in the link below, the prepareJsonResponse()
assumes the status code should be 500 in the case it is passed as the 2nd argument an instance of Illuminate\Auth\Access\AuthorizationException
https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Exceptions/Handler.php#L438
Questions
- Why is
AuthorizationException
not an instance ofHttpException
? It seems to me it should be, given that HTTP response codes 401 and 403 exist for cases such as this. - Why does
prepareJsonResponse
just assume the status code should be 500? It feels like I'm missing something here.