-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Error handler based on the request inputs #162
Comments
@beajeanm I believe this is the |
Thank you for your comment, but I know about that type (it's the one I describe in building it from scratch) and I don't see how that documentation address my need: Have the logging and back trace logic without using the template. |
@beajeanm If I understood you correctly, you'd like to implement a non-trivial error handler ( dream/src/http/error_handler.ml Lines 116 to 187 in 52d4da2
To proceed, I suggest writing a similar implementation in your own handler. I see at least two kinds of things that we may need to support you with:
There may be other things to do. I see that you want
However, I'm not sure what you mean by smart logging. The default error handler just formats the information in the The rest of the logic in the default error handler is about the backtrace. It is ultimately just based on Could you say exactly which pieces you'd like to reuse? |
@aantron I'm exploring using Dream with inertiajs.
I had a look at the default handler code and tried to add it to my own:
|
Could this be better addressed by passing the request (if available) to the template? Since Dream is in alpha and will remain so for a while, it's not a problem to add an extra argument if that's the best way to solve an issue. It seems like all the logging will already have been done, and you can generate the correct response based on the request. |
If that's on the table, then yes, it would make my error handling implementation trivial 😄 |
@beajeanm I decided to pass the whole
Could you take a look? I assume this is enough :) |
Yes, that works for me, thanks :) |
Ok, it's in |
This maybe more a question than a bug/feature request.
The error handler I'm trying to implement has some logic based on the incoming request that generated the error.
If building it from scratch (so implementing
Dream.error -> Dream.response option Lwt.t
) then it's all good, I have the (optional) request inerror.request
. But I'm missing all the bells an whistle that come with the default error handler. (Smart logging and stack trace in debug mode.)If I try to go through the template instead (so implementing
string option -> response -> response Lwt.t
) I lose access to all the request inputs.I can see how to workaround the problem for reponse based errors I generated by adding the required data to the reponse locals. But that only cover part of the errors, and it doesn't work for the reponses generated by another middleware (e.g.
Dream.not_found
)Is there something I'm missing?
Is there a way for me to access the logging and backtrace printing without using the error template?
The text was updated successfully, but these errors were encountered: