contributte / apitte

:wrench: An opinionated and enjoyable API framework based on Nette Framework. Supporting content negotiation, debugging, middlewares, attributes, annotations and loving openapi/swagger.
https://contributte.org/packages/contributte/apitte/
MIT License
61 stars 36 forks source link

Pass ApiRequest to ErrorHandler #139

Closed martenb closed 3 years ago

martenb commented 4 years ago

Is there a reason to not pass ApiRequest to ErrorHandler?

I have two use cases, where i need ApiRequest in ErrorHandler 1) log the request on error 2) cors: i need the request to correctly setup Access-Control-Allow-Origin

f3l1x commented 4 years ago

I get it why you need it. What about to create some DispatchException(original, request)? It could be more extendable.

martenb commented 4 years ago

You mean something like this?

IErrorHandler::handle(Throwable $error, DispatchException $exception)
f3l1x commented 4 years ago

So close, IErrorHandler::handle(DispatchException $e), $e->getError(), $e->getRequest().

martenb commented 4 years ago

Ok, and DispatchException not implements Throwable, just simple object?

f3l1x commented 4 years ago

Hmmmm, good point. If it ends with Exception it should implement it. Otherwise we can rename it to DispatchError and thus it will be simple. It's up to you.

martenb commented 4 years ago

Done

vody105 commented 3 years ago

@f3l1x are we including this in v0.7?

f3l1x commented 3 years ago

Yep, it will be in 0.7.