Compare commits
1 Commits
v0.7.5
...
34c60ffb98
Author | SHA1 | Date | |
---|---|---|---|
|
34c60ffb98 |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -6,24 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [0.7.5] - 2025-07-24
|
## [0.7.3] - 2025-07-21
|
||||||
|
|
||||||
### Added
|
|
||||||
- print big inner
|
|
||||||
|
|
||||||
### Other
|
|
||||||
- more error correction
|
|
||||||
- correct error test to not be as verbose
|
|
||||||
|
|
||||||
## [0.7.4] - 2025-07-24
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- cleanup aggregate error for single error
|
|
||||||
|
|
||||||
## [0.7.3] - 2025-07-24
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- automatic conversion from anyhow::Error and access to aggregate errors
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- *(deps)* update all dependencies (#30)
|
- *(deps)* update all dependencies (#30)
|
||||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -278,7 +278,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "notmad"
|
name = "notmad"
|
||||||
version = "0.7.4"
|
version = "0.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.7.5"
|
version = "0.7.3"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
mad = { path = "crates/mad" }
|
mad = { path = "crates/mad" }
|
||||||
|
@@ -11,16 +11,16 @@ mod waiter;
|
|||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum MadError {
|
pub enum MadError {
|
||||||
#[error("component: {0:#?}")]
|
#[error("component failed: {0}")]
|
||||||
Inner(#[source] anyhow::Error),
|
Inner(#[source] anyhow::Error),
|
||||||
|
|
||||||
#[error("component: {run:#?}")]
|
#[error("component(s) failed: {run}")]
|
||||||
RunError { run: anyhow::Error },
|
RunError { run: anyhow::Error },
|
||||||
|
|
||||||
#[error("component(s) failed: {close}")]
|
#[error("component(s) failed: {close}")]
|
||||||
CloseError { close: anyhow::Error },
|
CloseError { close: anyhow::Error },
|
||||||
|
|
||||||
#[error("component(s): {0}")]
|
#[error("component(s) failed: {0}")]
|
||||||
AggregateError(AggregateError),
|
AggregateError(AggregateError),
|
||||||
|
|
||||||
#[error("setup not defined")]
|
#[error("setup not defined")]
|
||||||
@@ -30,33 +30,13 @@ pub enum MadError {
|
|||||||
CloseNotDefined,
|
CloseNotDefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<anyhow::Error> for MadError {
|
|
||||||
fn from(value: anyhow::Error) -> Self {
|
|
||||||
Self::Inner(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AggregateError {
|
pub struct AggregateError {
|
||||||
errors: Vec<MadError>,
|
errors: Vec<MadError>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AggregateError {
|
|
||||||
pub fn get_errors(&self) -> &[MadError] {
|
|
||||||
&self.errors
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for AggregateError {
|
impl Display for AggregateError {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
if self.errors.is_empty() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.errors.len() == 1 {
|
|
||||||
return f.write_str(&self.errors.first().unwrap().to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
f.write_str("MadError::AggregateError: (")?;
|
f.write_str("MadError::AggregateError: (")?;
|
||||||
|
|
||||||
for error in &self.errors {
|
for error in &self.errors {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use notmad::{Component, Mad, MadError};
|
use notmad::{Component, Mad};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
@@ -137,20 +137,3 @@ async fn test_can_shutdown_gracefully() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_can_easily_transform_error() -> anyhow::Result<()> {
|
|
||||||
fn fallible() -> anyhow::Result<()> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn inner() -> Result<(), MadError> {
|
|
||||||
fallible()?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
inner()?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user