}
}
-impl<E: CargoError> FromError<E> for Box<CargoError> {
- fn from_error(error: E) -> Box<CargoError> {
- box error as Box<CargoError>
- }
-}
-
-macro_rules! from_error {
- ($ty:ty) => {
- impl FromError<$ty> for $ty {
- fn from_error(error: $ty) -> $ty {
- error
- }
- }
- }
-}
-
impl Show for Box<CargoError> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
try!(write!(f, "{}", self.description()));
fn description(&self) -> String { self.to_string() }
}
-from_error!(IoError);
-
impl CargoError for TomlError {
fn description(&self) -> String { self.to_string() }
}
-from_error!(TomlError);
-
impl CargoError for fmt::Error {
fn description(&self) -> String {
"formatting failed".to_string()
}
}
-from_error!(fmt::Error);
-
impl CargoError for curl::ErrCode {
fn description(&self) -> String { self.to_string() }
}
-from_error!(curl::ErrCode);
-
impl CargoError for json::DecoderError {
fn description(&self) -> String { self.to_string() }
}
-from_error!(json::DecoderError);
-
pub struct ProcessError {
pub msg: String,
pub exit: Option<ProcessExit>,
pub cause: Option<Box<CargoError>>
}
-from_error!(ProcessError);
-
impl Show for ProcessError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let exit = match self.exit {
}
}
-from_error!(CliError);
-
impl CargoError for docopt::Error {
fn description(&self) -> String {
match *self {
fn is_human(&self) -> bool { true }
}
-from_error!(docopt::Error);
-
impl CargoError for url::ParseError {
fn description(&self) -> String { self.to_string() }
}
-from_error!(url::ParseError);
-
impl CargoError for git2::Error {
fn description(&self) -> String { self.to_string() }
}
-from_error!(git2::Error);
-
impl CliError {
pub fn new<S: Str>(error: S, code: uint) -> CliError {
let error = human(error.as_slice().to_string());