Cleanup error handling
This commit is contained in:
parent
739862bc35
commit
8d76bd5c57
2 changed files with 9 additions and 9 deletions
|
@ -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()
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue