Repository navigation
Replies: 2 comments 1 reply
|
For anyone coming after this, I ended up grabbing the code from rocket_anyhow and using it in my project. The crate itself is pinned against an older version of Rocket. |
0 replies
|
Another option for solving this issue would be wrapper either A true solution would probably look like a custom Responder impl, something like this: impl<'r> Responder<'r, 'static> for Error {
fn respond_to(self, req: &'r Request<'_>) -> response::Result<'static> {
Response::build_from(json!({
"status": 500,
"error": format!("{}", self),
}).respond_to(req)?)
.status(Status::InternalServerError)
.ok()
}
} |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm currently trying to build out a small Rocket REST API that primarily wraps database calls. Normally I use anyhow for making error handling easy, but I don't think it works with Rocket currently. Please correct me if that's wrong. So then I went my backup plan on using an error enum. Using thiserror, an abridged example would be:
Or so I thought. When I try and derive
Responderon my error type, the issue is thatsqlx::Errordoes not implement it, so it doesn't work. I'm under the impression I can't be alone in this, but I've struggled thus far to find any resources that directly address the correct way to solve this since, I assume (or at least hope) there is an intended way to do this.For reference, the error for the above is:
Apologies if I missed another discussion, but it's hard to search for things that are about
?.All reactions