mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-27 02:41:53 +00:00
* the only way to begin is by beginning * chore: Convert over 3444 migration * fix imports * wip * feat: convert volume * convert: system.rs * wip(convert): Setup * wip properties * wip notifications * wip * wip migration * wip init * wip auth/control * wip action * wip control * wiip 034 * wip 344 * wip some more versions converted * feat: Reserialize the version of the db * wip rest of the versions * wip s9pk/manifest * wip wifi * chore: net/keys * chore: net/dns * wip net/dhcp * wip manager manager-map * gut dependency errors * wip update/mod * detect breakages locally for updates * wip: manager/mod * wip: manager/health * wip: backup/target/mod * fix: Typo addresses * clean control.rs * fix system package id * switch to btreemap for now * config wip * wip manager/mod * install wip Co-authored-by: J H <Blu-J@users.noreply.github.com> * chore: Update the last of the errors * feat: Change the prelude de to borrow * feat: Adding in some more things * chore: add to the prelude * chore: Small fixes * chore: Fixing the small errors * wip: Cleaning up check errors * wip: Fix some of the issues * chore: Fix setup * chore:fix version * chore: prelude, mod, http_reader * wip backup_bulk * chore: Last of the errors * upadte package.json * chore: changes needed for a build * chore: Removing some of the linting errors in the manager * chore: Some linting 101 * fix: Wrong order of who owns what * chore: Remove the unstable * chore: Remove the test in the todo * @dr-bonez did a refactoring on the backup * chore: Make sure that there can only be one override guard at a time * resolve most todos * wip: Add some more tracing to debug an error * wip: Use a mv instead of rename * wip: Revert some of the missing code segments found earlier * chore: Make the build * chore: Something about the lib looks like it iis broken * wip: More instrument and dev working * kill netdummy before creating it * better db analysis tools * fixes from testing * fix: Make add start the service * fix status after install * make wormhole * fix missing icon file * fix data url for icons * fix: Bad deser * bugfixes * fix: Backup * fix: Some of the restor * fix: Restoring works * update frontend patch-db types * hack it in (#2424) * hack it in * optimize * slightly cleaner * handle config pointers * dependency config errs * fix compat * cache docker * fix dependency expectation * fix dependency auto-config --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: Matt Hill <mattnine@protonmail.com> Co-authored-by: J H <Blu-J@users.noreply.github.com> Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
61 lines
1.5 KiB
Rust
61 lines
1.5 KiB
Rust
use color_eyre::eyre::eyre;
|
|
pub use models::{Error, ErrorKind, OptionExt, ResultExt};
|
|
|
|
#[derive(Debug, Default)]
|
|
pub struct ErrorCollection(Vec<Error>);
|
|
impl ErrorCollection {
|
|
pub fn new() -> Self {
|
|
Self::default()
|
|
}
|
|
|
|
pub fn handle<T, E: Into<Error>>(&mut self, result: Result<T, E>) -> Option<T> {
|
|
match result {
|
|
Ok(a) => Some(a),
|
|
Err(e) => {
|
|
self.0.push(e.into());
|
|
None
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn into_result(self) -> Result<(), Error> {
|
|
if self.0.is_empty() {
|
|
Ok(())
|
|
} else {
|
|
Err(Error::new(eyre!("{}", self), ErrorKind::MultipleErrors))
|
|
}
|
|
}
|
|
}
|
|
impl From<ErrorCollection> for Result<(), Error> {
|
|
fn from(e: ErrorCollection) -> Self {
|
|
e.into_result()
|
|
}
|
|
}
|
|
impl<T, E: Into<Error>> Extend<Result<T, E>> for ErrorCollection {
|
|
fn extend<I: IntoIterator<Item = Result<T, E>>>(&mut self, iter: I) {
|
|
for item in iter {
|
|
self.handle(item);
|
|
}
|
|
}
|
|
}
|
|
impl std::fmt::Display for ErrorCollection {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
for (idx, e) in self.0.iter().enumerate() {
|
|
if idx > 0 {
|
|
write!(f, "; ")?;
|
|
}
|
|
write!(f, "{}", e)?;
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! ensure_code {
|
|
($x:expr, $c:expr, $fmt:expr $(, $arg:expr)*) => {
|
|
if !($x) {
|
|
return Err(crate::error::Error::new(color_eyre::eyre::eyre!($fmt, $($arg, )*), $c));
|
|
}
|
|
};
|
|
}
|