Skip to content

Is there any way to handle ALL errors in a Rocket application? #1235

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

Closed
silvioprog opened this issue Feb 19, 2020 · 2 comments
Closed

Is there any way to handle ALL errors in a Rocket application? #1235

silvioprog opened this issue Feb 19, 2020 · 2 comments
Labels
question A question (converts to discussion)

Comments

@silvioprog
Copy link

Hi.

I would like to intercept all possible errors in a Rocket application, something like this:

impl<'r> Responder<'r> for ??? {
    fn respond_to(self, req: &Request) -> response::Result<'r> {
        status::Custom(Status::InternalServerError, self.to_string()).respond_to(req)
    }
}

So, is there any type to declare instead of ??? and intercept ANY error (from Serde, Diesel, std::io and so on) in the application?

Thank you!

@jebrosen
Copy link
Collaborator

Not currently, and I don't think we would add something so wide-reaching. Depending on what you want to do with it exactly, it may not even be possible in stable rust (see also #1232 (comment) RE: non_static_type_id). If you can provide more details on why you want a global error handler such as this I might be able to help more.

@jebrosen jebrosen added the question A question (converts to discussion) label Feb 29, 2020
@SergioBenitez
Copy link
Member

I am happy to revisit this with a compelling use-case, as requested by @jebrosen. Until then, I'm closing this out in favor of #1232.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question (converts to discussion)
Projects
None yet
Development

No branches or pull requests

3 participants