use std::sync::Arc;
use std::fmt;
use failure::Error;
use cluster::upload::Stats;
#[derive(Debug, Fail, Clone)]
pub enum ErrorKind {
#[fail(display="deadline reached")]
DeadlineReached,
#[fail(display="some hosts rejected the download")]
Rejected,
#[doc(hidden)]
#[fail(display="undefined error")]
__Nonexhaustive,
}
#[derive(Debug, Fail)]
pub enum UploadErr {
Fatal(Error),
NetworkError(ErrorKind, Arc<Stats>),
#[doc(hidden)]
__Nonexhaustive,
}
impl fmt::Display for UploadErr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::UploadErr::*;
match *self {
Fatal(ref e) => write!(f, "fatal error: {:?}", e),
NetworkError(ref kind, ref stats) => {
write!(f, "network error: {}. Overall progress: {}",
kind, stats.one_line_progress())
}
__Nonexhaustive => write!(f, "undefined error"),
}
}
}
#[derive(Debug, Fail)]
pub enum FetchErr {
#[fail(display="{:?}", _0)]
Fatal(Error),
#[doc(hidden)]
#[fail(display="undefined error")]
__Nonexhaustive,
}