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

JsonStrategy offers no way to log exceptions #204

Closed shadowhand closed 6 years ago

shadowhand commented 6 years ago

The current implementation of getExceptionHandler() offers no way to log exceptions that are caught. This is extremely bad for debugging, as there is no way to know what the underlying exception was.

The JsonStrategy should probably use PSR-3 LoggerAwareInterface and the anonymous class modified to make use of it. Or at least have a callable $onException handler that will be triggered when an exception is caught.

Also worth noting that Exception is used instead of Throwable, which means that not all errors are being caught by this middleware.

philipobenito commented 6 years ago

Maybe we could add a throwable handler, optionally at first as it’s a breaking change. Then the exception handler can proxy out to the throwable handler. Then we can unify for the next major release.

philipobenito commented 6 years ago

Covered by #205