mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 06:19:44 +00:00
chore: moving to color_eyre
This commit is contained in:
committed by
Aiden McClelland
parent
36bae894a9
commit
81164f974f
222
appmgr/Cargo.lock
generated
222
appmgr/Cargo.lock
generated
@@ -2,6 +2,21 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "aes"
|
||||
version = "0.7.5"
|
||||
@@ -44,6 +59,15 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.44"
|
||||
@@ -117,6 +141,21 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.61"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base-x"
|
||||
version = "0.2.8"
|
||||
@@ -390,7 +429,7 @@ version = "2.33.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"ansi_term 0.11.0",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"strsim 0.8.0",
|
||||
@@ -399,6 +438,33 @@ dependencies = [
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color-eyre"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f1885697ee8a177096d42f158922251a41973117f6d8a234cee94b9509157b7"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"color-spantrace",
|
||||
"eyre",
|
||||
"indenter",
|
||||
"once_cell",
|
||||
"owo-colors",
|
||||
"tracing-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color-spantrace"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6eee477a4a8a72f4addd4de416eb56d54bc307b284d6601bafdee1f4ea462d1"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"owo-colors",
|
||||
"tracing-core",
|
||||
"tracing-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const_fn"
|
||||
version = "0.4.8"
|
||||
@@ -759,7 +825,6 @@ name = "embassy-os"
|
||||
version = "0.3.0-pre.0"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"avahi-sys",
|
||||
"base32",
|
||||
@@ -768,6 +833,7 @@ dependencies = [
|
||||
"chrono",
|
||||
"ciborium",
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"cookie_store 0.15.0",
|
||||
"digest",
|
||||
"divrem",
|
||||
@@ -824,6 +890,9 @@ dependencies = [
|
||||
"tokio-util",
|
||||
"toml",
|
||||
"torut",
|
||||
"tracing",
|
||||
"tracing-futures",
|
||||
"tracing-subscriber",
|
||||
"typed-builder",
|
||||
"url",
|
||||
]
|
||||
@@ -890,6 +959,16 @@ dependencies = [
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "eyre"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "221239d1d5ea86bf5d6f91c9d6bc3646ffe471b08ff9b0f91c44f115ac969d2b"
|
||||
dependencies = [
|
||||
"indenter",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fd-lock-rs"
|
||||
version = "0.1.3"
|
||||
@@ -1100,6 +1179,12 @@ dependencies = [
|
||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7"
|
||||
|
||||
[[package]]
|
||||
name = "git-version"
|
||||
version = "0.3.5"
|
||||
@@ -1337,6 +1422,12 @@ dependencies = [
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indenter"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.7.0"
|
||||
@@ -1559,6 +1650,15 @@ dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
|
||||
dependencies = [
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.9"
|
||||
@@ -1603,6 +1703,16 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c835948974f68e0bd58636fc6c5b1fbff7b297e3046f11b3b3c18bbac012c6d"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
|
||||
dependencies = [
|
||||
"adler",
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.7.13"
|
||||
@@ -1803,6 +1913,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.26.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.8.0"
|
||||
@@ -1871,6 +1990,12 @@ dependencies = [
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "owo-colors"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2386b4ebe91c2f7f51082d4cefa145d030e33a1842a96b12e4885cc3c01f7a55"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.2"
|
||||
@@ -2341,6 +2466,9 @@ name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
dependencies = [
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
@@ -2483,6 +2611,12 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
@@ -2783,6 +2917,15 @@ dependencies = [
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "740223c51853f3145fe7c90360d2d4232f2b62e3449489c207eccde818979982"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "0.1.1"
|
||||
@@ -3471,9 +3614,21 @@ checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"pin-project-lite 0.2.7",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.29",
|
||||
"quote 1.0.9",
|
||||
"syn 1.0.77",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.20"
|
||||
@@ -3483,6 +3638,69 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-error"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4d7c0b83d4a500748fa5879461652b361edf5c9d51ede2a2ac03875ca185e24"
|
||||
dependencies = [
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-futures"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
|
||||
dependencies = [
|
||||
"pin-project",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-serde"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.2.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71"
|
||||
dependencies = [
|
||||
"ansi_term 0.12.1",
|
||||
"chrono",
|
||||
"lazy_static",
|
||||
"matchers",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
"tracing-serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "treediff"
|
||||
version = "4.0.0"
|
||||
|
||||
@@ -44,7 +44,6 @@ sound = []
|
||||
|
||||
[dependencies]
|
||||
aes = { version = "0.7.5", features = ["ctr"] }
|
||||
anyhow = "1.0.44"
|
||||
async-trait = "0.1.51"
|
||||
avahi-sys = { git = "https://github.com/Start9Labs/avahi-sys", version = "0.10.0", branch = "feature/dynamic-linking", features = [
|
||||
"dynamic",
|
||||
@@ -54,6 +53,7 @@ basic-cookies = "0.1.4"
|
||||
bollard = "0.11.0"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
clap = "2.33"
|
||||
color-eyre = "0.5"
|
||||
cookie_store = "0.15.0"
|
||||
digest = "0.9.0"
|
||||
divrem = "1.0.0"
|
||||
@@ -117,6 +117,9 @@ tokio-tar = { git = "https://github.com/dr-bonez/tokio-tar.git" }
|
||||
tokio-tungstenite = "0.14.0"
|
||||
tokio-util = { version = "0.6.8", features = ["io"] }
|
||||
torut = "0.2.0"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.2"
|
||||
tracing-futures="0.2"
|
||||
typed-builder = "0.9.1"
|
||||
url = { version = "2.2.2", features = ["serde"] }
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ use std::collections::BTreeMap;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::eyre;
|
||||
use indexmap::IndexSet;
|
||||
use patch_db::HasModel;
|
||||
use rpc_toolkit::command;
|
||||
@@ -131,7 +131,7 @@ impl Action {
|
||||
true,
|
||||
)
|
||||
.await?
|
||||
.map_err(|e| Error::new(anyhow!("{}", e.1), crate::ErrorKind::Action))
|
||||
.map_err(|e| Error::new(eyre!("{}", e.1), crate::ErrorKind::Action))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ pub async fn action(
|
||||
.await
|
||||
} else {
|
||||
Err(Error::new(
|
||||
anyhow!("Action not found in manifest"),
|
||||
eyre!("Action not found in manifest"),
|
||||
crate::ErrorKind::NotFound,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use basic_cookies::Cookie;
|
||||
use chrono::{DateTime, Utc};
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::eyre;
|
||||
use http::header::COOKIE;
|
||||
use http::HeaderValue;
|
||||
use rpc_toolkit::command;
|
||||
@@ -90,10 +90,7 @@ pub async fn login(
|
||||
.password;
|
||||
ensure_code!(
|
||||
argon2::verify_encoded(&pw_hash, password.as_bytes()).map_err(|_| {
|
||||
Error::new(
|
||||
anyhow!("Password Incorrect"),
|
||||
crate::ErrorKind::Authorization,
|
||||
)
|
||||
Error::new(eyre!("Password Incorrect"), crate::ErrorKind::Authorization)
|
||||
})?,
|
||||
crate::ErrorKind::Authorization,
|
||||
"Password Incorrect"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use patch_db::HasModel;
|
||||
use regex::NoExpand;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -36,7 +36,7 @@ impl BackupActions {
|
||||
false,
|
||||
)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{}", e.1))
|
||||
.map_err(|e| eyre!("{}", e.1))
|
||||
.with_kind(crate::ErrorKind::Backup)?;
|
||||
Ok(NoOutput)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ impl BackupActions {
|
||||
false,
|
||||
)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{}", e.1))
|
||||
.map_err(|e| eyre!("{}", e.1))
|
||||
.with_kind(crate::ErrorKind::Restore)?;
|
||||
Ok(NoOutput)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use embassy::context::{DiagnosticContext, RpcContext};
|
||||
use embassy::db::subscribe;
|
||||
use embassy::middleware::auth::auth;
|
||||
@@ -218,20 +218,22 @@ async fn inner_main(
|
||||
futures::try_join!(
|
||||
server.map_err(|e| Error::new(e, ErrorKind::Network)),
|
||||
revision_cache_task.map_err(|e| Error::new(
|
||||
anyhow!("{}", e).context("Revision Cache daemon panicked!"),
|
||||
eyre!("{}", e).wrap_err("Revision Cache daemon panicked!"),
|
||||
ErrorKind::Unknown
|
||||
)),
|
||||
ws_server.map_err(|e| Error::new(e, ErrorKind::Network)),
|
||||
status_daemon.map_err(|e| Error::new(
|
||||
e.context("Status Sync daemon panicked!"),
|
||||
e.wrap_err("Status Sync daemon panicked!"),
|
||||
ErrorKind::Unknown
|
||||
)),
|
||||
health_daemon.map_err(|e| Error::new(
|
||||
e.context("Health Check daemon panicked!"),
|
||||
e.wrap_err("Health Check daemon panicked!"),
|
||||
ErrorKind::Unknown
|
||||
)),
|
||||
tor_health_daemon.map_err(|e| Error::new(
|
||||
e.wrap_err("Tor Health daemon panicked!"),
|
||||
ErrorKind::Unknown
|
||||
)),
|
||||
tor_health_daemon
|
||||
.map_err(|e| Error::new(e.context("Tor Health daemon panicked!"), ErrorKind::Unknown)),
|
||||
)?;
|
||||
|
||||
rpc_ctx.managers.empty().await?;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use nix::sys::signal::Signal;
|
||||
use patch_db::HasModel;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -47,7 +47,7 @@ impl ConfigActions {
|
||||
)
|
||||
.await
|
||||
.and_then(|res| {
|
||||
res.map_err(|e| Error::new(anyhow!("{}", e.1), crate::ErrorKind::ConfigGen))
|
||||
res.map_err(|e| Error::new(eyre!("{}", e.1), crate::ErrorKind::ConfigGen))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ impl ConfigActions {
|
||||
.await
|
||||
.and_then(|res| {
|
||||
res.map_err(|e| {
|
||||
Error::new(anyhow!("{}", e.1), crate::ErrorKind::ConfigRulesViolation)
|
||||
Error::new(eyre!("{}", e.1), crate::ErrorKind::ConfigRulesViolation)
|
||||
})
|
||||
})?;
|
||||
Ok(SetResult {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use bollard::container::KillContainerOptions;
|
||||
use color_eyre::eyre::eyre;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
use indexmap::IndexSet;
|
||||
use itertools::Itertools;
|
||||
@@ -167,7 +167,7 @@ pub async fn get(
|
||||
.get(&mut db, true)
|
||||
.await?
|
||||
.to_owned()
|
||||
.ok_or_else(|| Error::new(anyhow!("{} has no config", id), crate::ErrorKind::NotFound))?;
|
||||
.ok_or_else(|| Error::new(eyre!("{} has no config", id), crate::ErrorKind::NotFound))?;
|
||||
let version = pkg_model
|
||||
.clone()
|
||||
.manifest()
|
||||
@@ -302,9 +302,7 @@ pub fn configure<'a, Db: DbHandle>(
|
||||
.get(db, true)
|
||||
.await?
|
||||
.to_owned()
|
||||
.ok_or_else(|| {
|
||||
Error::new(anyhow!("{} has no config", id), crate::ErrorKind::NotFound)
|
||||
})?;
|
||||
.ok_or_else(|| Error::new(eyre!("{} has no config", id), crate::ErrorKind::NotFound))?;
|
||||
let version = pkg_model.clone().manifest().version().get(db, true).await?;
|
||||
let dependencies = pkg_model
|
||||
.clone()
|
||||
|
||||
@@ -4,8 +4,8 @@ use std::net::{Ipv4Addr, SocketAddr};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::eyre;
|
||||
use cookie_store::CookieStore;
|
||||
use reqwest::Proxy;
|
||||
use reqwest_cookie_store::CookieStoreMutex;
|
||||
@@ -92,7 +92,7 @@ impl CliContext {
|
||||
});
|
||||
let cookie_store = Arc::new(CookieStoreMutex::new(if cookie_path.exists() {
|
||||
CookieStore::load_json(BufReader::new(File::open(&cookie_path)?))
|
||||
.map_err(|e| anyhow!("{}", e))
|
||||
.map_err(|e| eyre!("{}", e))
|
||||
.with_kind(crate::ErrorKind::Deserialization)?
|
||||
} else {
|
||||
CookieStore::default()
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::io::Read;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::eyre;
|
||||
use rpc_toolkit::Context;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -48,7 +48,7 @@ impl SdkContext {
|
||||
/// BLOCKING
|
||||
pub fn developer_key(&self) -> Result<ed25519_dalek::Keypair, Error> {
|
||||
if !self.developer_key_path.exists() {
|
||||
return Err(Error::new(anyhow!("Developer Key does not exist! Please run `embassy-sdk init` before running this command."), crate::ErrorKind::Uninitialized));
|
||||
return Err(Error::new(eyre!("Developer Key does not exist! Please run `embassy-sdk init` before running this command."), crate::ErrorKind::Uninitialized));
|
||||
}
|
||||
let mut keypair_buf = [0; ed25519_dalek::KEYPAIR_LENGTH];
|
||||
File::open(&self.developer_key_path)?.read_exact(&mut keypair_buf)?;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use chrono::Utc;
|
||||
use color_eyre::eyre::eyre;
|
||||
use patch_db::DbHandle;
|
||||
use rpc_toolkit::command;
|
||||
|
||||
@@ -54,9 +54,7 @@ pub async fn start(
|
||||
.managers
|
||||
.get(&(id.clone(), version))
|
||||
.await
|
||||
.ok_or_else(|| {
|
||||
Error::new(anyhow!("Manager not found"), crate::ErrorKind::Docker)
|
||||
})?,
|
||||
.ok_or_else(|| Error::new(eyre!("Manager not found"), crate::ErrorKind::Docker))?,
|
||||
)
|
||||
.await?;
|
||||
status.save(&mut tx).await?;
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::future::Future;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use futures::{FutureExt, SinkExt, StreamExt};
|
||||
use patch_db::json_ptr::JsonPointer;
|
||||
use patch_db::{Dump, Revision};
|
||||
@@ -67,7 +67,7 @@ async fn ws_handler<
|
||||
.into_iter()
|
||||
.find(|c| c.get_name() == "session")
|
||||
.ok_or_else(|| {
|
||||
Error::new(anyhow!("UNAUTHORIZED"), crate::ErrorKind::Authorization)
|
||||
Error::new(eyre!("UNAUTHORIZED"), crate::ErrorKind::Authorization)
|
||||
})?;
|
||||
if let Err(e) =
|
||||
crate::middleware::auth::is_authed(&ctx, &hash_token(id.get_value())).await
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use emver::VersionRange;
|
||||
use futures::future::BoxFuture;
|
||||
use futures::FutureExt;
|
||||
@@ -439,7 +439,7 @@ impl DependencyConfig {
|
||||
Some(old),
|
||||
)
|
||||
.await?
|
||||
.map_err(|e| Error::new(anyhow!("{}", e.1), crate::ErrorKind::AutoConfigure))
|
||||
.map_err(|e| Error::new(eyre!("{}", e.1), crate::ErrorKind::AutoConfigure))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ pub fn break_transitive<'a, Db: DbHandle>(
|
||||
.into_owned()
|
||||
.ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("{} not in listed dependencies", dependency),
|
||||
eyre!("{} not in listed dependencies", dependency),
|
||||
crate::ErrorKind::Database,
|
||||
)
|
||||
})?
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::{self, eyre};
|
||||
use futures::TryStreamExt;
|
||||
use indexmap::IndexSet;
|
||||
use regex::Regex;
|
||||
@@ -54,7 +54,7 @@ pub async fn get_vendor<P: AsRef<Path>>(path: P) -> Result<Option<String>, Error
|
||||
Path::new(SYS_BLOCK_PATH)
|
||||
.join(path.as_ref().strip_prefix("/dev").map_err(|_| {
|
||||
Error::new(
|
||||
anyhow!("not a canonical block device"),
|
||||
eyre!("not a canonical block device"),
|
||||
crate::ErrorKind::BlockDevice,
|
||||
)
|
||||
})?)
|
||||
@@ -74,7 +74,7 @@ pub async fn get_model<P: AsRef<Path>>(path: P) -> Result<Option<String>, Error>
|
||||
Path::new(SYS_BLOCK_PATH)
|
||||
.join(path.as_ref().strip_prefix("/dev").map_err(|_| {
|
||||
Error::new(
|
||||
anyhow!("not a canonical block device"),
|
||||
eyre!("not a canonical block device"),
|
||||
crate::ErrorKind::BlockDevice,
|
||||
)
|
||||
})?)
|
||||
@@ -141,7 +141,7 @@ pub async fn list() -> Result<Vec<DiskInfo>, Error> {
|
||||
)
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
anyhow::Error::from(e).context(DISK_PATH),
|
||||
eyre::Error::from(e).wrap_err(DISK_PATH),
|
||||
crate::ErrorKind::Filesystem,
|
||||
)
|
||||
})
|
||||
@@ -312,7 +312,7 @@ pub async fn mount_encfs<P0: AsRef<Path>, P1: AsRef<Path>>(
|
||||
let mut err = String::new();
|
||||
stderr.read_to_string(&mut err).await?;
|
||||
if !encfs.wait().await?.success() {
|
||||
Err(Error::new(anyhow!("{}", err), crate::ErrorKind::Filesystem))
|
||||
Err(Error::new(eyre!("{}", err), crate::ErrorKind::Filesystem))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
@@ -350,7 +350,7 @@ pub async fn bind<P0: AsRef<Path>, P1: AsRef<Path>>(
|
||||
.await
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
e.source.context(format!(
|
||||
e.source.wrap_err(format!(
|
||||
"Binding {} to {}",
|
||||
src.as_ref().display(),
|
||||
dst.as_ref().display(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use patch_db::Revision;
|
||||
use rpc_toolkit::yajrc::RpcError;
|
||||
|
||||
@@ -128,7 +128,7 @@ impl Display for ErrorKind {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
pub source: anyhow::Error,
|
||||
pub source: color_eyre::eyre::Error,
|
||||
pub kind: ErrorKind,
|
||||
pub revision: Option<Revision>,
|
||||
}
|
||||
@@ -138,7 +138,7 @@ impl Display for Error {
|
||||
}
|
||||
}
|
||||
impl Error {
|
||||
pub fn new<E: Into<anyhow::Error>>(source: E, kind: ErrorKind) -> Self {
|
||||
pub fn new<E: Into<color_eyre::eyre::Error>>(source: E, kind: ErrorKind) -> Self {
|
||||
Error {
|
||||
source: source.into(),
|
||||
kind,
|
||||
@@ -203,7 +203,7 @@ impl From<bollard::errors::Error> for Error {
|
||||
}
|
||||
impl From<torut::control::ConnError> for Error {
|
||||
fn from(e: torut::control::ConnError) -> Self {
|
||||
Error::new(anyhow!("{:?}", e), ErrorKind::Tor)
|
||||
Error::new(eyre!("{:?}", e), ErrorKind::Tor)
|
||||
}
|
||||
}
|
||||
impl From<std::net::AddrParseError> for Error {
|
||||
@@ -213,7 +213,7 @@ impl From<std::net::AddrParseError> for Error {
|
||||
}
|
||||
impl From<openssl::error::ErrorStack> for Error {
|
||||
fn from(e: openssl::error::ErrorStack) -> Self {
|
||||
Error::new(anyhow!("OpenSSL ERROR:\n{}", e), ErrorKind::OpenSsl)
|
||||
Error::new(eyre!("OpenSSL ERROR:\n{}", e), ErrorKind::OpenSsl)
|
||||
}
|
||||
}
|
||||
impl From<Error> for RpcError {
|
||||
@@ -250,7 +250,7 @@ where
|
||||
}
|
||||
impl<T, E> ResultExt<T, E> for Result<T, E>
|
||||
where
|
||||
anyhow::Error: From<E>,
|
||||
color_eyre::eyre::Error: From<E>,
|
||||
{
|
||||
fn with_kind(self, kind: ErrorKind) -> Result<T, Error> {
|
||||
self.map_err(|e| Error {
|
||||
@@ -266,9 +266,9 @@ where
|
||||
) -> Result<T, Error> {
|
||||
self.map_err(|e| {
|
||||
let (kind, ctx) = f(&e);
|
||||
let source = anyhow::Error::from(e);
|
||||
let source = color_eyre::eyre::Error::from(e);
|
||||
let ctx = format!("{}: {}", ctx, source);
|
||||
let source = source.context(ctx);
|
||||
let source = source.wrap_err(ctx);
|
||||
Error {
|
||||
kind,
|
||||
source: source.into(),
|
||||
@@ -282,7 +282,7 @@ where
|
||||
macro_rules! ensure_code {
|
||||
($x:expr, $c:expr, $fmt:expr $(, $arg:expr)*) => {
|
||||
if !($x) {
|
||||
return Err(crate::Error::new(anyhow!($fmt, $($arg, )*), $c));
|
||||
return Err(crate::Error::new(eyre!($fmt, $($arg, )*), $c));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::process::Stdio;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::{self, eyre};
|
||||
use emver::VersionRange;
|
||||
use futures::TryStreamExt;
|
||||
use http::StatusCode;
|
||||
@@ -102,7 +102,7 @@ pub async fn install(
|
||||
}
|
||||
_ => {
|
||||
return Err(Error::new(
|
||||
anyhow!("Cannot install over a package in a transient state"),
|
||||
eyre!("Cannot install over a package in a transient state"),
|
||||
crate::ErrorKind::InvalidRequest,
|
||||
))
|
||||
}
|
||||
@@ -165,7 +165,7 @@ pub async fn uninstall_impl(ctx: RpcContext, id: PackageId) -> Result<WithRevisi
|
||||
}) => (manifest, static_files, installed),
|
||||
_ => {
|
||||
return Err(Error::new(
|
||||
anyhow!("Package is not installed."),
|
||||
eyre!("Package is not installed."),
|
||||
crate::ErrorKind::NotFound,
|
||||
));
|
||||
}
|
||||
@@ -466,19 +466,19 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
.spawn()?;
|
||||
let tee_in = tee.stdin.take().ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("Could not write to stdin of tee"),
|
||||
eyre!("Could not write to stdin of tee"),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
})?;
|
||||
let mut tee_out = tee.stdout.take().ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("Could not read from stdout of tee"),
|
||||
eyre!("Could not read from stdout of tee"),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
})?;
|
||||
let load_in = load.stdin.take().ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("Could not write to stdin of docker load"),
|
||||
eyre!("Could not write to stdin of docker load"),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
})?;
|
||||
@@ -490,7 +490,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
let res = load.wait_with_output().await?;
|
||||
if !res.status.success() {
|
||||
Err(Error::new(
|
||||
anyhow!(
|
||||
eyre!(
|
||||
"{}",
|
||||
String::from_utf8(res.stderr)
|
||||
.unwrap_or_else(|e| format!("Could not parse stderr: {}", e))
|
||||
@@ -764,7 +764,7 @@ pub async fn load_images<P: AsRef<Path>>(datadir: P) -> Result<(), Error> {
|
||||
ReadDirStream::new(tokio::fs::read_dir(&docker_dir).await?)
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
anyhow::Error::from(e).context(format!("{:?}", &docker_dir)),
|
||||
eyre::Report::from(e).wrap_err(format!("{:?}", &docker_dir)),
|
||||
crate::ErrorKind::Filesystem,
|
||||
)
|
||||
})
|
||||
@@ -772,7 +772,7 @@ pub async fn load_images<P: AsRef<Path>>(datadir: P) -> Result<(), Error> {
|
||||
ReadDirStream::new(tokio::fs::read_dir(pkg_id.path()).await?)
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
anyhow::Error::from(e).context(pkg_id.path().display().to_string()),
|
||||
eyre::Report::from(e).wrap_err(pkg_id.path().display().to_string()),
|
||||
crate::ErrorKind::Filesystem,
|
||||
)
|
||||
})
|
||||
@@ -784,7 +784,7 @@ pub async fn load_images<P: AsRef<Path>>(datadir: P) -> Result<(), Error> {
|
||||
.spawn()?;
|
||||
let load_in = load.stdin.take().ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("Could not write to stdin of docker load"),
|
||||
eyre!("Could not write to stdin of docker load"),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
})?;
|
||||
@@ -793,7 +793,7 @@ pub async fn load_images<P: AsRef<Path>>(datadir: P) -> Result<(), Error> {
|
||||
let res = load.wait_with_output().await?;
|
||||
if !res.status.success() {
|
||||
Err(Error::new(
|
||||
anyhow!(
|
||||
eyre!(
|
||||
"{}",
|
||||
String::from_utf8(res.stderr).unwrap_or_else(|e| format!(
|
||||
"Could not parse stderr: {}",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use std::process::Stdio;
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::eyre;
|
||||
use futures::TryStreamExt;
|
||||
use rpc_toolkit::command;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -123,10 +123,12 @@ pub async fn fetch_logs(
|
||||
.args(args)
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()?;
|
||||
let out =
|
||||
BufReader::new(child.stdout.take().ok_or_else(|| {
|
||||
Error::new(anyhow!("No stdout available"), crate::ErrorKind::Journald)
|
||||
})?);
|
||||
let out = BufReader::new(
|
||||
child
|
||||
.stdout
|
||||
.take()
|
||||
.ok_or_else(|| Error::new(eyre!("No stdout available"), crate::ErrorKind::Journald))?,
|
||||
);
|
||||
|
||||
let journalctl_entries = LinesStream::new(out.lines());
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::Arc;
|
||||
use std::task::Poll;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use bollard::container::StopContainerOptions;
|
||||
use color_eyre::eyre::eyre;
|
||||
use patch_db::DbHandle;
|
||||
use sqlx::{Executor, Sqlite};
|
||||
use tokio::sync::watch::error::RecvError;
|
||||
@@ -100,7 +100,7 @@ impl ManagerMap {
|
||||
res.into_iter().fold(Ok(()), |res, x| match (res, x) {
|
||||
(Ok(()), x) => x,
|
||||
(Err(e), Ok(())) => Err(e),
|
||||
(Err(e1), Err(e2)) => Err(Error::new(anyhow!("{}, {}", e1.source, e2.source), e1.kind)),
|
||||
(Err(e1), Err(e2)) => Err(Error::new(eyre!("{}, {}", e1.source, e2.source), e1.kind)),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -182,10 +182,7 @@ async fn run_main(state: &Arc<ManagerSharedState>) -> Result<Result<(), (i32, St
|
||||
Poll::Ready(res) => {
|
||||
return res
|
||||
.map_err(|_| {
|
||||
Error::new(
|
||||
anyhow!("Manager runtime panicked!"),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
Error::new(eyre!("Manager runtime panicked!"), crate::ErrorKind::Docker)
|
||||
})
|
||||
.and_then(|a| a)
|
||||
}
|
||||
@@ -213,7 +210,7 @@ async fn run_main(state: &Arc<ManagerSharedState>) -> Result<Result<(), (i32, St
|
||||
.get(id)
|
||||
.ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("interface {} missing key", id),
|
||||
eyre!("interface {} missing key", id),
|
||||
crate::ErrorKind::Tor,
|
||||
)
|
||||
})?
|
||||
@@ -225,12 +222,7 @@ async fn run_main(state: &Arc<ManagerSharedState>) -> Result<Result<(), (i32, St
|
||||
.await?;
|
||||
let res = runtime
|
||||
.await
|
||||
.map_err(|_| {
|
||||
Error::new(
|
||||
anyhow!("Manager runtime panicked!"),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
})
|
||||
.map_err(|_| Error::new(eyre!("Manager runtime panicked!"), crate::ErrorKind::Docker))
|
||||
.and_then(|a| a);
|
||||
state
|
||||
.ctx
|
||||
@@ -350,7 +342,7 @@ impl Manager {
|
||||
pub async fn stop(&self) -> Result<(), Error> {
|
||||
self.shared.on_stop.send(OnStop::Sleep).map_err(|_| {
|
||||
Error::new(
|
||||
anyhow!("Manager has already been shutdown"),
|
||||
eyre!("Manager has already been shutdown"),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
})?;
|
||||
@@ -382,7 +374,7 @@ impl Manager {
|
||||
pub async fn start(&self) -> Result<(), Error> {
|
||||
self.shared.on_stop.send(OnStop::Restart).map_err(|_| {
|
||||
Error::new(
|
||||
anyhow!("Manager has already been shutdown"),
|
||||
eyre!("Manager has already been shutdown"),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
})?;
|
||||
@@ -442,7 +434,7 @@ impl Manager {
|
||||
if let Some(thread) = self.thread.take().await {
|
||||
thread.await.map_err(|e| {
|
||||
Error::new(
|
||||
anyhow!("Manager thread panicked: {}", e),
|
||||
eyre!("Manager thread panicked: {}", e),
|
||||
crate::ErrorKind::Docker,
|
||||
)
|
||||
})?;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use anyhow::anyhow;
|
||||
use basic_cookies::Cookie;
|
||||
use color_eyre::eyre::eyre;
|
||||
use digest::Digest;
|
||||
use futures::future::BoxFuture;
|
||||
use futures::{FutureExt, TryFutureExt};
|
||||
@@ -29,7 +29,7 @@ pub fn get_id(req: &RequestParts) -> Result<String, Error> {
|
||||
}
|
||||
}
|
||||
Err(Error::new(
|
||||
anyhow!("UNAUTHORIZED"),
|
||||
eyre!("UNAUTHORIZED"),
|
||||
crate::ErrorKind::Authorization,
|
||||
))
|
||||
}
|
||||
@@ -50,7 +50,7 @@ pub async fn is_authed(ctx: &RpcContext, id: &str) -> Result<(), Error> {
|
||||
.await?;
|
||||
if session.rows_affected() == 0 {
|
||||
return Err(Error::new(
|
||||
anyhow!("UNAUTHORIZED"),
|
||||
eyre!("UNAUTHORIZED"),
|
||||
crate::ErrorKind::Authorization,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ pub async fn diagnostic<M: Metadata>(
|
||||
if let Err(e) = rpc_res {
|
||||
if e.code == -32601 {
|
||||
*e = Error::new(
|
||||
anyhow::anyhow!(
|
||||
color_eyre::eyre::eyre!(
|
||||
"{} is not available on the Diagnostic API",
|
||||
method
|
||||
),
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
|
||||
use aes::cipher::{CipherKey, NewCipher, Nonce, StreamCipher};
|
||||
use aes::Aes256Ctr;
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use futures::future::BoxFuture;
|
||||
use futures::{FutureExt, Stream};
|
||||
use hmac::Hmac;
|
||||
@@ -193,7 +193,7 @@ pub fn encrypt<
|
||||
&req.headers,
|
||||
res_parts,
|
||||
Err(Error::new(
|
||||
anyhow!("Must be encrypted"),
|
||||
eyre!("Must be encrypted"),
|
||||
crate::ErrorKind::Authorization,
|
||||
)
|
||||
.into()),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use emver::VersionRange;
|
||||
use indexmap::IndexMap;
|
||||
use patch_db::HasModel;
|
||||
@@ -45,7 +45,7 @@ impl Migrations {
|
||||
)
|
||||
.await?
|
||||
.map_err(|e| {
|
||||
Error::new(anyhow!("{}", e.1), crate::ErrorKind::MigrationFailed)
|
||||
Error::new(eyre!("{}", e.1), crate::ErrorKind::MigrationFailed)
|
||||
})?,
|
||||
)
|
||||
} else {
|
||||
@@ -78,7 +78,7 @@ impl Migrations {
|
||||
)
|
||||
.await?
|
||||
.map_err(|e| {
|
||||
Error::new(anyhow!("{}", e.1), crate::ErrorKind::MigrationFailed)
|
||||
Error::new(eyre!("{}", e.1), crate::ErrorKind::MigrationFailed)
|
||||
})?,
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use futures::TryStreamExt;
|
||||
use indexmap::IndexSet;
|
||||
use itertools::Either;
|
||||
@@ -86,10 +86,7 @@ impl Interfaces {
|
||||
Ok(if let Either::Right(r) = qr {
|
||||
let mut buf = [0; 64];
|
||||
buf.clone_from_slice(r.key.get(0..64).ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("Invalid Tor Key Length"),
|
||||
crate::ErrorKind::Database,
|
||||
)
|
||||
Error::new(eyre!("Invalid Tor Key Length"), crate::ErrorKind::Database)
|
||||
})?);
|
||||
Some((InterfaceId::from(Id::try_from(r.interface)?), buf.into()))
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use openssl::asn1::{Asn1Integer, Asn1Time};
|
||||
use openssl::bn::{BigNum, MsbOption};
|
||||
use openssl::ec::{EcGroup, EcKey};
|
||||
@@ -115,7 +115,7 @@ impl SslStore {
|
||||
let n = sqlx::query!("UPDATE certificates SET priv_key_pem = ?, certificate_pem = ?, updated_at = datetime('now') WHERE lookup_string = ?", key_str, cert_str, lookup_string).execute(&self.secret_store).await?;
|
||||
if n.rows_affected() == 0 {
|
||||
return Err(Error::new(
|
||||
anyhow!(
|
||||
eyre!(
|
||||
"Attempted to update non-existent certificate: {}",
|
||||
lookup_string
|
||||
),
|
||||
|
||||
@@ -2,8 +2,8 @@ use std::collections::BTreeMap;
|
||||
use std::net::{Ipv4Addr, SocketAddr};
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::eyre;
|
||||
use futures::future::BoxFuture;
|
||||
use futures::FutureExt;
|
||||
use reqwest::Client;
|
||||
@@ -66,12 +66,11 @@ where
|
||||
.tor_key;
|
||||
|
||||
let mut buf = [0; 64];
|
||||
buf.clone_from_slice(key.get(0..64).ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("Invalid Tor Key Length"),
|
||||
crate::ErrorKind::Database,
|
||||
)
|
||||
})?);
|
||||
buf.clone_from_slice(
|
||||
key.get(0..64).ok_or_else(|| {
|
||||
Error::new(eyre!("Invalid Tor Key Length"), crate::ErrorKind::Database)
|
||||
})?,
|
||||
);
|
||||
Ok(buf.into())
|
||||
}
|
||||
|
||||
@@ -158,10 +157,7 @@ impl TorControllerInner {
|
||||
self.connection
|
||||
.as_mut()
|
||||
.ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("Missing Tor Control Connection"),
|
||||
ErrorKind::Unknown,
|
||||
)
|
||||
Error::new(eyre!("Missing Tor Control Connection"), ErrorKind::Unknown)
|
||||
})?
|
||||
.add_onion_v3(
|
||||
&key,
|
||||
@@ -194,7 +190,7 @@ impl TorControllerInner {
|
||||
self.connection
|
||||
.as_mut()
|
||||
.ok_or_else(|| {
|
||||
Error::new(anyhow!("Missing Tor Control Connection"), ErrorKind::Tor)
|
||||
Error::new(eyre!("Missing Tor Control Connection"), ErrorKind::Tor)
|
||||
})?
|
||||
.del_onion(
|
||||
&key.public()
|
||||
@@ -219,7 +215,7 @@ impl TorControllerInner {
|
||||
.load_protocol_info()
|
||||
.await?
|
||||
.make_auth_data()?
|
||||
.ok_or_else(|| anyhow!("Cookie Auth Not Available"))
|
||||
.ok_or_else(|| eyre!("Cookie Auth Not Available"))
|
||||
.with_kind(crate::ErrorKind::Tor)?;
|
||||
conn.authenticate(&auth).await?;
|
||||
let mut connection: AuthenticatedConnection = conn.into_authenticated().await;
|
||||
@@ -243,7 +239,7 @@ impl TorControllerInner {
|
||||
);
|
||||
self.connection
|
||||
.as_mut()
|
||||
.ok_or_else(|| Error::new(anyhow!("Missing Tor Control Connection"), ErrorKind::Tor))?
|
||||
.ok_or_else(|| Error::new(eyre!("Missing Tor Control Connection"), ErrorKind::Tor))?
|
||||
.add_onion_v3(
|
||||
&self.embassyd_tor_key,
|
||||
false,
|
||||
@@ -290,7 +286,7 @@ impl TorControllerInner {
|
||||
.load_protocol_info()
|
||||
.await?
|
||||
.make_auth_data()?
|
||||
.ok_or_else(|| anyhow!("Cookie Auth Not Available"))
|
||||
.ok_or_else(|| eyre!("Cookie Auth Not Available"))
|
||||
.with_kind(crate::ErrorKind::Tor)?;
|
||||
new_conn.authenticate(&auth).await?;
|
||||
new_connection = new_conn.into_authenticated().await;
|
||||
@@ -339,7 +335,7 @@ impl TorControllerInner {
|
||||
async fn list_services(&mut self) -> Result<Vec<OnionAddressV3>, Error> {
|
||||
self.connection
|
||||
.as_mut()
|
||||
.ok_or_else(|| Error::new(anyhow!("Missing Tor Control Connection"), ErrorKind::Tor))?
|
||||
.ok_or_else(|| Error::new(eyre!("Missing Tor Control Connection"), ErrorKind::Tor))?
|
||||
.get_info("onions/current")
|
||||
.await?
|
||||
.lines()
|
||||
@@ -405,7 +401,7 @@ async fn test() {
|
||||
.unwrap()
|
||||
.make_auth_data()
|
||||
.unwrap()
|
||||
.ok_or_else(|| anyhow!("Cookie Auth Not Available"))
|
||||
.ok_or_else(|| eyre!("Cookie Auth Not Available"))
|
||||
.with_kind(crate::ErrorKind::Tor)
|
||||
.unwrap();
|
||||
conn.authenticate(&auth).await.unwrap();
|
||||
|
||||
@@ -25,13 +25,13 @@ pub async fn add(
|
||||
let wpa_supplicant = WpaCli { interface: "wlan0" }; // TODO: pull from config
|
||||
if !ssid.is_ascii() {
|
||||
return Err(Error::new(
|
||||
anyhow::anyhow!("SSID may not have special characters"),
|
||||
color_eyre::eyre::eyre!("SSID may not have special characters"),
|
||||
ErrorKind::Wifi,
|
||||
));
|
||||
}
|
||||
if !password.is_ascii() {
|
||||
return Err(Error::new(
|
||||
anyhow::anyhow!("WiFi Password may not have special characters"),
|
||||
color_eyre::eyre::eyre!("WiFi Password may not have special characters"),
|
||||
ErrorKind::Wifi,
|
||||
));
|
||||
}
|
||||
@@ -75,7 +75,7 @@ pub async fn add(
|
||||
pub async fn connect(#[arg] ssid: String) -> Result<(), Error> {
|
||||
if !ssid.is_ascii() {
|
||||
return Err(Error::new(
|
||||
anyhow::anyhow!("SSID may not have special characters"),
|
||||
color_eyre::eyre::eyre!("SSID may not have special characters"),
|
||||
ErrorKind::Wifi,
|
||||
));
|
||||
}
|
||||
@@ -113,7 +113,7 @@ pub async fn connect(#[arg] ssid: String) -> Result<(), Error> {
|
||||
pub async fn delete(#[arg] ssid: String) -> Result<(), Error> {
|
||||
if !ssid.is_ascii() {
|
||||
return Err(Error::new(
|
||||
anyhow::anyhow!("SSID may not have special characters"),
|
||||
color_eyre::eyre::eyre!("SSID may not have special characters"),
|
||||
ErrorKind::Wifi,
|
||||
));
|
||||
}
|
||||
@@ -128,7 +128,7 @@ pub async fn delete(#[arg] ssid: String) -> Result<(), Error> {
|
||||
if interface_connected("eth0").await? {
|
||||
wpa_supplicant.remove_network(&ssid).await?;
|
||||
} else {
|
||||
return Err(Error::new(anyhow::anyhow!("Forbidden: Deleting this Network would make your Embassy Unreachable. Either connect to ethernet or connect to a different WiFi network to remedy this."), ErrorKind::Wifi));
|
||||
return Err(Error::new(color_eyre::eyre::eyre!("Forbidden: Deleting this Network would make your Embassy Unreachable. Either connect to ethernet or connect to a different WiFi network to remedy this."), ErrorKind::Wifi));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,7 +401,7 @@ impl<'a> WpaCli<'a> {
|
||||
.await?;
|
||||
let e = || {
|
||||
Error::new(
|
||||
anyhow::anyhow!("Invalid output from wpa_cli signal_poll"),
|
||||
color_eyre::eyre::eyre!("Invalid output from wpa_cli signal_poll"),
|
||||
ErrorKind::Wifi,
|
||||
)
|
||||
};
|
||||
@@ -423,7 +423,7 @@ impl<'a> WpaCli<'a> {
|
||||
let m_id = self.check_network(ssid).await?;
|
||||
match m_id {
|
||||
None => Err(Error::new(
|
||||
anyhow::anyhow!("SSID Not Found"),
|
||||
color_eyre::eyre::eyre!("SSID Not Found"),
|
||||
ErrorKind::Wifi,
|
||||
)),
|
||||
Some(x) => {
|
||||
@@ -513,7 +513,7 @@ pub async fn interface_connected(interface: &str) -> Result<bool, Error> {
|
||||
|
||||
pub fn country_code_parse(code: &str, _matches: &ArgMatches<'_>) -> Result<CountryCode, Error> {
|
||||
CountryCode::for_alpha2(code).or(Err(Error::new(
|
||||
anyhow::anyhow!("Invalid Country Code: {}", code),
|
||||
color_eyre::eyre::eyre!("Invalid Country Code: {}", code),
|
||||
ErrorKind::Wifi,
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ use std::collections::{BTreeMap, HashMap};
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use color_eyre::eyre::eyre;
|
||||
use patch_db::PatchDb;
|
||||
use rpc_toolkit::command;
|
||||
use sqlx::SqlitePool;
|
||||
@@ -58,7 +58,7 @@ pub async fn list(
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
return Err(Error::new(
|
||||
anyhow!("Invalid Notification Data: {}", e),
|
||||
eyre!("Invalid Notification Data: {}", e),
|
||||
ErrorKind::ParseDbField,
|
||||
))
|
||||
}
|
||||
@@ -100,7 +100,7 @@ pub async fn list(
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
return Err(Error::new(
|
||||
anyhow!("Invalid Notification Data: {}", e),
|
||||
eyre!("Invalid Notification Data: {}", e),
|
||||
ErrorKind::ParseDbField,
|
||||
))
|
||||
}
|
||||
@@ -168,7 +168,7 @@ pub struct InvalidNotificationLevel(String);
|
||||
impl From<InvalidNotificationLevel> for crate::Error {
|
||||
fn from(val: InvalidNotificationLevel) -> Self {
|
||||
Error::new(
|
||||
anyhow!("Invalid Notification Level: {}", val.0),
|
||||
eyre!("Invalid Notification Level: {}", val.0),
|
||||
ErrorKind::ParseDbField,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use anyhow::anyhow;
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::eyre;
|
||||
use rpc_toolkit::command;
|
||||
use serde_json::Value;
|
||||
|
||||
@@ -26,7 +26,7 @@ pub async fn fetch_properties(ctx: RpcContext, id: PackageId) -> Result<Value, E
|
||||
.get(&mut db, true)
|
||||
.await?
|
||||
.to_owned()
|
||||
.ok_or_else(|| Error::new(anyhow!("{} is not installed", id), ErrorKind::NotFound))?;
|
||||
.ok_or_else(|| Error::new(eyre!("{} is not installed", id), ErrorKind::NotFound))?;
|
||||
if let Some(props) = manifest.properties {
|
||||
props
|
||||
.execute::<(), Value>(
|
||||
@@ -39,7 +39,7 @@ pub async fn fetch_properties(ctx: RpcContext, id: PackageId) -> Result<Value, E
|
||||
false,
|
||||
)
|
||||
.await?
|
||||
.map_err(|_| Error::new(anyhow!("Properties failure!"), ErrorKind::Docker))
|
||||
.map_err(|_| Error::new(eyre!("Properties failure!"), ErrorKind::Docker))
|
||||
.and_then(|a| Ok(a))
|
||||
} else {
|
||||
Ok(Value::Null)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::Write;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use ed25519_dalek::{PublicKey, Signature};
|
||||
use tokio::io::{AsyncRead, AsyncReadExt};
|
||||
|
||||
@@ -38,7 +38,7 @@ impl Header {
|
||||
reader.read_exact(&mut magic).await?;
|
||||
if magic != MAGIC {
|
||||
return Err(Error::new(
|
||||
anyhow!("Incorrect Magic"),
|
||||
eyre!("Incorrect Magic"),
|
||||
crate::ErrorKind::ParseS9pk,
|
||||
));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ impl Header {
|
||||
reader.read_exact(&mut version).await?;
|
||||
if version[0] != VERSION {
|
||||
return Err(Error::new(
|
||||
anyhow!("Unknown Version"),
|
||||
eyre!("Unknown Version"),
|
||||
crate::ErrorKind::ParseS9pk,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use rpc_toolkit::command;
|
||||
|
||||
use crate::context::SdkContext;
|
||||
@@ -40,7 +40,7 @@ pub fn pack(#[context] ctx: SdkContext, #[arg] path: Option<PathBuf>) -> Result<
|
||||
.with_kind(crate::ErrorKind::Deserialization)?
|
||||
} else {
|
||||
return Err(Error::new(
|
||||
anyhow!("manifest not found"),
|
||||
eyre!("manifest not found"),
|
||||
crate::ErrorKind::Pack,
|
||||
));
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use color_eyre::eyre::eyre;
|
||||
use futures::future::BoxFuture;
|
||||
use futures::{FutureExt, TryStreamExt};
|
||||
use rpc_toolkit::command;
|
||||
@@ -123,7 +123,7 @@ pub async fn execute_inner(
|
||||
) -> Result<String, Error> {
|
||||
if ctx.recovery_status.read().await.is_some() {
|
||||
return Err(Error::new(
|
||||
anyhow!("Cannot execute setup while in recovery!"),
|
||||
eyre!("Cannot execute setup while in recovery!"),
|
||||
crate::ErrorKind::InvalidRequest,
|
||||
));
|
||||
}
|
||||
@@ -173,7 +173,7 @@ pub async fn execute_inner(
|
||||
.map(|v| &*v.version < &emver::Version::new(0, 2, 8, 0))
|
||||
.unwrap_or(true)
|
||||
{
|
||||
return Err(Error::new(anyhow!("Unsupported version of EmbassyOS. Please update to at least 0.2.8 before recovering."), crate::ErrorKind::VersionIncompatible));
|
||||
return Err(Error::new(eyre!("Unsupported version of EmbassyOS. Please update to at least 0.2.8 before recovering."), crate::ErrorKind::VersionIncompatible));
|
||||
}
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = recover(ctx.clone(), guid, recovery_drive, recovery_password).await {
|
||||
@@ -206,7 +206,7 @@ async fn recover(
|
||||
recover_v3(&ctx, recovery_drive, recovery_password).await?;
|
||||
} else {
|
||||
return Err(Error::new(
|
||||
anyhow!("Unsupported version of EmbassyOS: {}", recovery_version),
|
||||
eyre!("Unsupported version of EmbassyOS: {}", recovery_version),
|
||||
crate::ErrorKind::VersionIncompatible,
|
||||
));
|
||||
}
|
||||
@@ -313,7 +313,7 @@ async fn recover_v2(ctx: &SetupContext, recovery_drive: DiskInfo) -> Result<(),
|
||||
.get(1)
|
||||
.ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("missing rootfs partition"),
|
||||
eyre!("missing rootfs partition"),
|
||||
crate::ErrorKind::Filesystem,
|
||||
)
|
||||
})?
|
||||
|
||||
@@ -36,7 +36,7 @@ impl SoundInterface {
|
||||
.await
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
anyhow::anyhow!("Sound file lock panicked: {}", e),
|
||||
color_eyre::eyre::eyre!("Sound file lock panicked: {}", e),
|
||||
ErrorKind::SoundError,
|
||||
)
|
||||
})?
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use chrono::Utc;
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::eyre;
|
||||
use rpc_toolkit::command;
|
||||
use sqlx::{Pool, Sqlite};
|
||||
|
||||
@@ -84,10 +84,7 @@ pub async fn add(#[context] ctx: RpcContext, #[arg] key: PubKey) -> Result<SshKe
|
||||
created_at,
|
||||
})
|
||||
}
|
||||
Some(_) => Err(Error::new(
|
||||
anyhow!("Duplicate ssh key"),
|
||||
ErrorKind::Duplicate,
|
||||
)),
|
||||
Some(_) => Err(Error::new(eyre!("Duplicate ssh key"), ErrorKind::Duplicate)),
|
||||
}
|
||||
}
|
||||
#[command(display(display_none))]
|
||||
@@ -102,7 +99,7 @@ pub async fn delete(#[context] ctx: RpcContext, #[arg] fingerprint: String) -> R
|
||||
// if not in DB, Err404
|
||||
if n == 0 {
|
||||
Err(Error {
|
||||
source: anyhow::anyhow!("SSH Key Not Found"),
|
||||
source: color_eyre::eyre::eyre!("SSH Key Not Found"),
|
||||
kind: crate::error::ErrorKind::NotFound,
|
||||
revision: None,
|
||||
})
|
||||
@@ -180,7 +177,7 @@ pub async fn sync_keys_from_db<P: AsRef<Path>>(pool: &Pool<Sqlite>, dest: P) ->
|
||||
.collect();
|
||||
let ssh_dir = dest.parent().ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("SSH Key File cannot be \"/\""),
|
||||
eyre!("SSH Key File cannot be \"/\""),
|
||||
crate::ErrorKind::Filesystem,
|
||||
)
|
||||
})?;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use color_eyre::eyre::eyre;
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use patch_db::{DbHandle, HasModel, Map, ModelData};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -60,7 +60,7 @@ pub async fn synchronize_all(ctx: &RpcContext) -> Result<(), Error> {
|
||||
))
|
||||
.await
|
||||
.ok_or_else(|| {
|
||||
Error::new(anyhow!("No Manager"), crate::ErrorKind::Docker)
|
||||
Error::new(eyre!("No Manager"), crate::ErrorKind::Docker)
|
||||
})?,
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -209,7 +209,7 @@ pub async fn metrics(
|
||||
) -> Result<Metrics, Error> {
|
||||
match ctx.metrics_cache.read().await.clone() {
|
||||
None => Err(Error {
|
||||
source: anyhow::anyhow!("No Metrics Found"),
|
||||
source: color_eyre::eyre::eyre!("No Metrics Found"),
|
||||
kind: ErrorKind::NotFound,
|
||||
revision: None,
|
||||
}),
|
||||
@@ -456,7 +456,7 @@ async fn get_proc_stat() -> Result<ProcStat, Error> {
|
||||
.map(|s| {
|
||||
s.parse::<u64>().map_err(|e| {
|
||||
Error::new(
|
||||
anyhow::anyhow!("Invalid /proc/stat column value: {}", e),
|
||||
color_eyre::eyre::eyre!("Invalid /proc/stat column value: {}", e),
|
||||
ErrorKind::ParseSysInfo,
|
||||
)
|
||||
})
|
||||
@@ -465,7 +465,7 @@ async fn get_proc_stat() -> Result<ProcStat, Error> {
|
||||
|
||||
if stats.len() < 10 {
|
||||
Err(Error {
|
||||
source: anyhow::anyhow!(
|
||||
source: color_eyre::eyre::eyre!(
|
||||
"Columns missing from /proc/stat. Need 10, found {}",
|
||||
stats.len()
|
||||
),
|
||||
@@ -525,7 +525,7 @@ async fn get_mem_info() -> Result<MetricsMemory, Error> {
|
||||
};
|
||||
fn get_num_kb(l: &str) -> Result<u64, Error> {
|
||||
let e = Error::new(
|
||||
anyhow::anyhow!("Invalid meminfo line: {}", l),
|
||||
color_eyre::eyre::eyre!("Invalid meminfo line: {}", l),
|
||||
ErrorKind::ParseSysInfo,
|
||||
);
|
||||
match l.split_whitespace().skip(1).next() {
|
||||
@@ -553,7 +553,7 @@ async fn get_mem_info() -> Result<MetricsMemory, Error> {
|
||||
}
|
||||
fn ensure_present(a: Option<u64>, field: &str) -> Result<u64, Error> {
|
||||
a.ok_or(Error::new(
|
||||
anyhow::anyhow!("{} missing from /proc/meminfo", field),
|
||||
color_eyre::eyre::eyre!("{} missing from /proc/meminfo", field),
|
||||
ErrorKind::ParseSysInfo,
|
||||
))
|
||||
}
|
||||
@@ -617,7 +617,7 @@ async fn get_disk_info() -> Result<MetricsDisk, Error> {
|
||||
.parse::<f64>()
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
anyhow::anyhow!("Could not parse disk size: {}", e),
|
||||
color_eyre::eyre::eyre!("Could not parse disk size: {}", e),
|
||||
ErrorKind::ParseSysInfo,
|
||||
)
|
||||
})?;
|
||||
@@ -626,7 +626,7 @@ async fn get_disk_info() -> Result<MetricsDisk, Error> {
|
||||
.parse::<f64>()
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
anyhow::anyhow!("Could not parse disk alloc: {}", e),
|
||||
color_eyre::eyre::eyre!("Could not parse disk alloc: {}", e),
|
||||
ErrorKind::ParseSysInfo,
|
||||
)
|
||||
})?;
|
||||
@@ -635,7 +635,7 @@ async fn get_disk_info() -> Result<MetricsDisk, Error> {
|
||||
.parse::<f64>()
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
anyhow::anyhow!("Could not parse disk alloc: {}", e),
|
||||
color_eyre::eyre::eyre!("Could not parse disk alloc: {}", e),
|
||||
ErrorKind::ParseSysInfo,
|
||||
)
|
||||
})?;
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::{eyre, Result};
|
||||
use digest::Digest;
|
||||
use emver::Version;
|
||||
use futures::Stream;
|
||||
@@ -183,7 +183,7 @@ async fn maybe_do_update(ctx: RpcContext) -> Result<Option<Arc<Revision>>, Error
|
||||
match &info.status {
|
||||
ServerStatus::Updating => {
|
||||
return Err(Error::new(
|
||||
anyhow!("Server is already updating!"),
|
||||
eyre!("Server is already updating!"),
|
||||
crate::ErrorKind::InvalidRequest,
|
||||
))
|
||||
}
|
||||
@@ -192,7 +192,7 @@ async fn maybe_do_update(ctx: RpcContext) -> Result<Option<Arc<Revision>>, Error
|
||||
}
|
||||
ServerStatus::BackingUp => {
|
||||
return Err(Error::new(
|
||||
anyhow!("Server is backing up!"),
|
||||
eyre!("Server is backing up!"),
|
||||
crate::ErrorKind::InvalidRequest,
|
||||
))
|
||||
}
|
||||
@@ -272,7 +272,7 @@ async fn query_mounted_label() -> Result<(NewLabel, CurrentLabel), Error> {
|
||||
|
||||
match &PARSE_COLOR.captures(&output).ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("Can't find pattern in {}", output),
|
||||
eyre!("Can't find pattern in {}", output),
|
||||
crate::ErrorKind::Filesystem,
|
||||
)
|
||||
})?[1]
|
||||
@@ -287,7 +287,7 @@ async fn query_mounted_label() -> Result<(NewLabel, CurrentLabel), Error> {
|
||||
)),
|
||||
e => {
|
||||
return Err(Error::new(
|
||||
anyhow!("Could not find a mounted resource for {}", e),
|
||||
eyre!("Could not find a mounted resource for {}", e),
|
||||
crate::ErrorKind::Filesystem,
|
||||
))
|
||||
}
|
||||
@@ -322,7 +322,7 @@ async fn download_file<'a, Db: DbHandle + 'a>(
|
||||
let hash_from_header: String = "".to_owned(); // download_request
|
||||
// .headers()
|
||||
// .get(HEADER_KEY)
|
||||
// .ok_or_else(|| Error::new(anyhow!("No {} in headers", HEADER_KEY), ErrorKind::Network))?
|
||||
// .ok_or_else(|| Error::new(eyre!("No {} in headers", HEADER_KEY), ErrorKind::Network))?
|
||||
// .to_str()
|
||||
// .with_kind(ErrorKind::InvalidRequest)?
|
||||
// .to_owned();
|
||||
@@ -373,7 +373,7 @@ async fn write_stream_to_label<Db: DbHandle>(
|
||||
async fn check_download(hash_from_header: &str, file_digest: Vec<u8>) -> Result<(), Error> {
|
||||
// if hex::decode(hash_from_header).with_kind(ErrorKind::Network)? != file_digest {
|
||||
// return Err(Error::new(
|
||||
// anyhow!("Hash sum does not match source"),
|
||||
// eyre!("Hash sum does not match source"),
|
||||
// ErrorKind::Network,
|
||||
// ));
|
||||
// }
|
||||
|
||||
@@ -100,7 +100,7 @@ where
|
||||
let mut buffer = Vec::new();
|
||||
reader.read_to_end(&mut buffer).await?;
|
||||
serde_yaml::from_slice(&buffer)
|
||||
.map_err(anyhow::Error::from)
|
||||
.map_err(color_eyre::eyre::Error::from)
|
||||
.with_kind(crate::ErrorKind::Deserialization)
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ where
|
||||
let mut buffer = Vec::new();
|
||||
reader.read_to_end(&mut buffer).await?;
|
||||
serde_toml::from_slice(&buffer)
|
||||
.map_err(anyhow::Error::from)
|
||||
.map_err(color_eyre::eyre::Error::from)
|
||||
.with_kind(crate::ErrorKind::Deserialization)
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ where
|
||||
let mut buffer = Vec::new();
|
||||
reader.read_to_end(&mut buffer).await?;
|
||||
serde_cbor::de::from_reader(buffer.as_slice())
|
||||
.map_err(anyhow::Error::from)
|
||||
.map_err(color_eyre::eyre::Error::from)
|
||||
.with_kind(crate::ErrorKind::Deserialization)
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ where
|
||||
let mut buffer = Vec::new();
|
||||
reader.read_to_end(&mut buffer).await?;
|
||||
serde_json::from_slice(&buffer)
|
||||
.map_err(anyhow::Error::from)
|
||||
.map_err(color_eyre::eyre::Error::from)
|
||||
.with_kind(crate::ErrorKind::Deserialization)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ use std::process::{exit, Stdio};
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use async_trait::async_trait;
|
||||
use clap::ArgMatches;
|
||||
use color_eyre::eyre::{self, eyre};
|
||||
use digest::Digest;
|
||||
use patch_db::{HasModel, Model};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
@@ -166,14 +166,14 @@ pub async fn daemon<F: FnMut() -> Fut, Fut: Future<Output = ()> + Send + 'static
|
||||
mut f: F,
|
||||
cooldown: std::time::Duration,
|
||||
mut shutdown: tokio::sync::broadcast::Receiver<Option<Shutdown>>,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
) -> Result<(), eyre::Error> {
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = shutdown.recv() => return Ok(()),
|
||||
_ = tokio::time::sleep(cooldown) => (),
|
||||
}
|
||||
match tokio::spawn(f()).await {
|
||||
Err(e) if e.is_panic() => return Err(anyhow!("daemon panicked!")),
|
||||
Err(e) if e.is_panic() => return Err(eyre!("daemon panicked!")),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -647,7 +647,7 @@ pub fn parse_stdin_deserializable<T: for<'de> Deserialize<'de>>(
|
||||
pub fn parse_duration(arg: &str, _: &ArgMatches<'_>) -> Result<Duration, Error> {
|
||||
let units_idx = arg.find(|c: char| c.is_alphabetic()).ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("Must specify units for duration"),
|
||||
eyre!("Must specify units for duration"),
|
||||
crate::ErrorKind::Deserialization,
|
||||
)
|
||||
})?;
|
||||
@@ -665,7 +665,7 @@ pub fn parse_duration(arg: &str, _: &ArgMatches<'_>) -> Result<Duration, Error>
|
||||
"us" => Ok(Duration::from_micros(num.parse()?)),
|
||||
"ns" => Ok(Duration::from_nanos(num.parse()?)),
|
||||
_ => Err(Error::new(
|
||||
anyhow!("Invalid units for duration"),
|
||||
eyre!("Invalid units for duration"),
|
||||
crate::ErrorKind::Deserialization,
|
||||
)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user