slimphp / Slim-Skeleton

Slim Framework 4 Skeleton Application
http://www.slimframework.com
MIT License
1.59k stars 479 forks source link

Error Handler status code improvement #220

Closed amireshoon closed 3 years ago

amireshoon commented 3 years ago

Added status code if an exception is not an instance of HttpExeception to trigger error and see deference that it makes throw an error.

 throw new Exception("This is a bad request", 400);
 // or
 throw new Exception("its not founded", 404);
l0gicgate commented 3 years ago

The problem with this assertion is that $exception->getCode() might not be a valid http status code, hence why it is only set with the HttpException on line 35. We know that those exceptions will return a valid status code while regular exceptions won't necessarily.