How to either create a hyper::Error or handle hyper::http::Error #2802
-
Let's say I have code like this:
This fails to compile with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
A |
Beta Was this translation helpful? Give feedback.
-
Thanks Sean. My n00b-ness showing through. I've previously shied away from those two approaches, trying to roll my own as I learn better how Rust works. But I've seen enough of both suggestions before that it's probably high time to try them. |
Beta Was this translation helpful? Give feedback.
A
hyper::Error
is not meant to be something that a user creates. You don't need to return one in your server handler. I imagine you probably want to because you also are handling request body errors? Here's what I would do: change your service error to a dynamic error type. Maybeanyhow
, or even justBox<dyn std::error::Error>
.