Skip to content

Error handler based on the request inputs #162

@beajeanm

Description

@beajeanm

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 in error.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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions