-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ErrorHandler interface limitations. #374
Comments
Sounds good to me. We should probably name the new interface |
The request handler provided to the HTTP server should be catching all exceptions and logging them as you desire. I don't see a reason to provide this functionality at a lower level, separate from the request handler. |
It should also be noted that Amp\Http\HttpStatus\DefaultErrorHandler make use of a blocking function ( file_get_contents() ) to read on resources/error.html |
It is using a blocking function, but the file loaded is part of the source code and read only a single time, so is not much different than loading a source file via the autoloader. |
Thinking further about this issue, perhaps we should provide a simple middleware which takes an |
Keep in mind that if I want to completely redesign all kinds of error pages, implementing ExceptionHandler as middleware would not be enough. I would have to implement both ExceptionHandler and ErrorHandler, because in case when malformed request in occurs, middlewares are not called, request object is not even created. In this case ErrorHandler will create error page with 40x code. |
This is true. I've opened a PR which demonstrates how an |
ErrorHandler is pretty useless now, it does not give me the ability to implement my own Error handler.
By Error handler I mean my own logic that takes an exception and request as input arguments.
I would like to complete replace all of this default logic that hardcoded in AbstractHttpDriver now:
http-server/src/Driver/Internal/AbstractHttpDriver.php
Line 90 in 26001b1
with my own implementation and log exceptions by myself as I need, but now I can't.
I can't event intercept an exception to get access to the stack trace. Current ErrorHandler only gives access to exception code. Having only code in Error handler is absolutely not enough.
Here is an example how from my point of view ErrorHandler interface should look like.
Then the default ErrorHandler implementation could do the default logging that is now hardcoded in AbstractHttpDriver and generate Response for the browser, and I could completely replace the implementation having access to the exception itself as I need.
Are you interested in such changes? If so, I could work on it. But of course it will not be backwards compatible.
What do you think about it?
The text was updated successfully, but these errors were encountered: