thephpleague / route

Fast PSR-7 based routing and dispatch component including PSR-15 middleware, built on top of FastRoute.
http://route.thephpleague.com
MIT License
651 stars 126 forks source link

Get detailed error message when using JSON strategy #268

Closed zkwbbr closed 4 years ago

zkwbbr commented 4 years ago

Say you have an undefined variable in your controller handler: e.g., $foo['bar'];

Currently when you run this using JSON strategy, you'll get something like this:

{
  "status_code": 500,
  "reason_phrase": "Undefined index: bar"
}

Is there a way for this error message to give more details? E.g., what line number or file the error happens?

delboy1978uk commented 4 years ago

why not just extend it and use your own?

zkwbbr commented 4 years ago

@delboy1978uk Yeah I ended up using ApplicationStrategy instead and customizing from there.

philipobenito commented 4 years ago

The base strategies exist only as a starting point and to make it easy for them to be extended with a custom strategy. For example, with the JsonStrategy, I will usually extend that and overload the error handlers for my specific use, but everything else can just pass through