tauri/lib/rust/src/updater/error.rs
nothingismagick 13734c338b
chore(merge) dev to master (#4)
* feat(readme) clarifications and styling
* fix(readme) logo position
* feat(scaffolding) folders, templates, rust, c, node WOW
* feat(proton) initial packages for webview and binding-rust
* feat(proton) new folder structure
* chore(compliance) readmes and licenses
* chore(npm) create package.json
* chore(proton) rename packages and create lib/rust
* chore(proton) create templates directory
* feat(rust) rustfmt tab_spaces = 2
* feat(rust) run fmt and fix template structure
* chore(npm) update package
- package name (@quasar/proton)
- node 10, npm 6.6, yarn 1.17.3 (security)
- .gitignore
- .npmignore
- add docs and spec dirs

Signed-off-by: Daniel Thompson-Yvetot <denjell@quasar.dev>
2019-07-14 14:50:49 +02:00

79 lines
1.7 KiB
Rust

use super::super::file;
use super::super::http;
use super::super::version;
use reqwest;
use std;
use zip::result::ZipError;
#[derive(Debug)]
pub enum Error {
Updater(String),
Release(String),
Network(String),
Config(String),
Io(std::io::Error),
Zip(ZipError),
File(file::Error),
Version(version::Error),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
use Error::*;
match *self {
Updater(ref s) => write!(f, "UpdaterError: {}", s),
Release(ref s) => write!(f, "ReleaseError: {}", s),
Network(ref s) => write!(f, "NetworkError: {}", s),
Config(ref s) => write!(f, "ConfigError: {}", s),
Io(ref e) => write!(f, "IoError: {}", e),
Zip(ref e) => write!(f, "ZipError: {}", e),
File(ref e) => write!(f, "FileError: {}", e),
Version(ref e) => write!(f, "VersionError: {}", e),
}
}
}
impl std::error::Error for Error {
fn description(&self) -> &str {
"Updater Error"
}
fn cause(&self) -> Option<&std::error::Error> {
use Error::*;
Some(match *self {
Io(ref e) => e,
_ => return None,
})
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
}
impl From<file::Error> for Error {
fn from(e: file::Error) -> Self {
Error::File(e)
}
}
impl From<http::Error> for Error {
fn from(e: http::Error) -> Self {
Error::Network(e.to_string())
}
}
impl From<reqwest::Error> for Error {
fn from(e: reqwest::Error) -> Self {
Error::Network(e.to_string())
}
}
impl From<version::Error> for Error {
fn from(e: version::Error) -> Self {
Error::Version(e)
}
}