Closed eyalgrossdev closed 3 years ago
Hey, I think the problem lies in your own Handler.php, specifically \App\Library\Exceptions\Handler.php
If you look at your stack trace, you are trying to access the session of the request, but for REST API requests, typically there is no session.
#0 ...\\app\\Library\\Exceptions\\Handler.php(159): Illuminate\\Http\\Request->session()
If you are still unsure, you might want to post the code for your Handler class there.
Actual Behaviour
I have a couple of custom middleware classes that perform custom authentication and authorization for my api. In both I am throwing several custom exceptions all registered in the provider as per recommendation in the wiki
Each custom Exception extends
Symfony\Component\HttpKernel\Exception\HttpException;
again as recommended in the wiki.Upon testing the exceptions each is being thrown correctly with the custom error message being displayed in Postman except for the
InvalidApiKey
exception which displays asHere is the relevant stacktrace from the log
Expected Behaviour
I expect this exception to be thrown and caught in the same way as the others. There is no difference between them.
Steps to Reproduce
I hit the endpoint in Postman with an invalid api key which would throw the exception
Possible Solutions
No idea unfortunately. :(