1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#[derive(Debug)] pub enum Error { PackageNotMember, EnginePresent, FlutterNotFound, GenSnapshotNotFound, FormatNotSupported, CargoError, FlutterError, NotCalledWithCargo, Which(which::Error), Io(std::io::Error), Toml(toml::de::Error), Utf8(std::str::Utf8Error), Err(failure::Error), } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { Error::PackageNotMember => write!(f, "Package is not a member of the workspace"), Error::EnginePresent => write!(f, "Flutter engine already downloaded"), Error::FlutterNotFound => write!(f, "Couldn't find flutter sdk"), Error::GenSnapshotNotFound => write!(f, "Couldn't find gen_snapshot"), Error::FormatNotSupported => write!(f, "Format not supported"), Error::CargoError => write!(f, "Cargo did not exit successfully"), Error::FlutterError => write!(f, "Flutter did not exit successfully"), Error::NotCalledWithCargo => { write!(f, "This binary may only be called via `cargo flutter`.") } Error::Which(error) => error.fmt(f), Error::Io(error) => error.fmt(f), Error::Toml(error) => error.fmt(f), Error::Utf8(error) => error.fmt(f), Error::Err(error) => error.fmt(f), } } } impl std::error::Error for Error {} impl From<which::Error> for Error { fn from(error: which::Error) -> Self { Error::Which(error) } } impl From<std::io::Error> for Error { fn from(error: std::io::Error) -> Self { Error::Io(error) } } impl From<toml::de::Error> for Error { fn from(error: toml::de::Error) -> Self { Error::Toml(error) } } impl From<std::str::Utf8Error> for Error { fn from(error: std::str::Utf8Error) -> Self { Error::Utf8(error) } } impl From<failure::Error> for Error { fn from(error: failure::Error) -> Self { Error::Err(error) } }