Compare commits
5 Commits
16cedd44f8
...
v0.7.4
Author | SHA1 | Date | |
---|---|---|---|
b941dc9a76 | |||
5da3c83c12
|
|||
a16bee8e37 | |||
a61f00a79d
|
|||
2bd9bd7b8e |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [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
|
||||||
|
- *(deps)* update all dependencies (#30)
|
||||||
|
|
||||||
## [0.7.2] - 2025-06-25
|
## [0.7.2] - 2025-06-25
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
15
Cargo.lock
generated
15
Cargo.lock
generated
@@ -34,9 +34,9 @@ checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.87"
|
version = "0.1.88"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d556ec1359574147ec0c4fc5eb525f3f23263a592b1a9c07e0a75b427de55c97"
|
checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -278,7 +278,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "notmad"
|
name = "notmad"
|
||||||
version = "0.7.2"
|
version = "0.7.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -388,13 +388,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.9.0"
|
version = "0.9.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
|
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand_chacha",
|
"rand_chacha",
|
||||||
"rand_core",
|
"rand_core",
|
||||||
"zerocopy 0.8.14",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -599,9 +598,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-util"
|
name = "tokio-util"
|
||||||
version = "0.7.13"
|
version = "0.7.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078"
|
checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.7.2"
|
version = "0.7.4"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
mad = { path = "crates/mad" }
|
mad = { path = "crates/mad" }
|
||||||
|
@@ -30,13 +30,33 @@ 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};
|
use notmad::{Component, Mad, MadError};
|
||||||
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,3 +137,20 @@ 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