Open MarkSwanson opened 6 years ago
Sorry for the late reply. I was doing homework these days : ( I didn't really catch you. Can you show me a complete code snippet so that I can test it and see if i can fix it?
Maybe I can change hyper::Error
to
use std::error::Error as StdError;
pub type BoxFut =
Box<Future<Item = Response<Body>, Error = Box<StdError + Send + Sync>> + Send>;
The question is that I don't know if it is what you want.
I have never thought about this Error
type problem before. When writing a web application, I don't really return an Error
. Instead, a Response
with status code will be returned under any circumstances.
Also, people can use lookup
or get_value
to implement their own function for custom Handle
, which I didn't mention clearly in the document. My bad.
I'm testing out hyper and radix-router and I've noticed that it's not possible to create a hyper::Error (by design). The problem is that radix-router BoxFut forces you to create a hyper::Error on error. This means I can't use Rust Futures the way they were designed ( for_each() is designed to break out on Err - but I can't create a hyper::Error). It seems I posted this as a hyper issue, but it seems to be a radix-router issue instead. https://github.com/hyperium/hyper/issues/1658
Would the proper way to fix this (enable folks to use Rust futures for_each() etc.) be to change the radix-router Error type to something compatible with std::Error / failure::Error ?
Or, am I misusing the Error type in some way and there is already a best practice for handling this?
Thanks!