diff --git a/src/commands/relay.rs b/src/commands/relay.rs index 88e116d..0c2dfbc 100644 --- a/src/commands/relay.rs +++ b/src/commands/relay.rs @@ -1,5 +1,4 @@ use std::error::Error; -use std::io::ErrorKind; use std::net::ToSocketAddrs; use std::sync::{ Arc, @@ -39,6 +38,8 @@ use webmetro::{ stream_parser::StreamEbml }; +use super::to_hyper_error; + type BodyStream = Box<Stream<Item = Chunk, Error = HyperError>>; struct RelayServer(Arc<Mutex<Channel>>); @@ -60,7 +61,7 @@ impl RelayServer { fn post_stream<I: AsRef<[u8]>, S: Stream<Item = I> + 'static>(&self, stream: S) -> BodyStream where S::Error: Error + Send { let source = stream - .map_err(|err| WebmetroError::Unknown(Box::new(err))) + .map_err(WebmetroError::from_err) .parse_ebml().chunk_webm(); let sink = Transmitter::new(self.get_channel()); @@ -69,12 +70,8 @@ impl RelayServer { .into_stream() .map(|_| empty()) .map_err(|err| { - let io_err = match err { - WebmetroError::IoError(io_err) => io_err, - _ => ErrorKind::InvalidData.into() - }; - println!("Post failed: {}", &io_err); - io_err + println!("{}", err); + to_hyper_error(err) }) .flatten() ) diff --git a/src/commands/send.rs b/src/commands/send.rs index c070444..d7932f6 100644 --- a/src/commands/send.rs +++ b/src/commands/send.rs @@ -60,7 +60,10 @@ pub fn run(handle: Handle, args: &ArgMatches) -> Box<Future<Item=(), Error=Webme chunk_stream = Box::new(chunk_stream.throttle()); } - let request_body_stream = Box::new(chunk_stream.map_err(to_hyper_error)) as BoxedHyperStream; + let request_body_stream = Box::new(chunk_stream.map_err(|err| { + eprintln!("{}", &err); + to_hyper_error(err) + })) as BoxedHyperStream; Box::new(future::lazy(move || { url_str.parse().map_err(WebmetroError::from_err)