1 Commits

Author SHA1 Message Date
cuddle-please
036abcc407 chore(release): 0.8.2
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2025-11-14 01:38:56 +00:00
4 changed files with 29 additions and 76 deletions

View File

@@ -6,10 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.9.0] - 2025-11-15
## [0.8.2] - 2025-11-14
### Added
- mad not properly surfaces panics
- add publish
- add readme

View File

@@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2"
[workspace.package]
version = "0.9.0"
version = "0.8.2"
[workspace.dependencies]
mad = { path = "crates/mad" }

View File

@@ -77,11 +77,8 @@
use futures::stream::FuturesUnordered;
use futures_util::StreamExt;
use std::{error::Error, fmt::Display, sync::Arc};
use tokio::{
signal::unix::{SignalKind, signal},
task::JoinError,
};
use std::{fmt::Display, sync::Arc, error::Error};
use tokio::signal::unix::{SignalKind, signal};
use tokio_util::sync::CancellationToken;
@@ -104,13 +101,15 @@ pub enum MadError {
/// Error that occurred during the run phase of a component.
#[error(transparent)]
RunError { run: anyhow::Error },
RunError {
run: anyhow::Error
},
/// Error that occurred during the close phase of a component.
#[error("component(s) failed during close")]
CloseError {
#[source]
close: anyhow::Error,
close: anyhow::Error
},
/// Multiple errors from different components.
@@ -502,32 +501,11 @@ impl Mad {
tracing::debug!(component = name, "mad running");
let handle = tokio::spawn(async move { comp.run(job_cancellation).await });
tokio::select! {
_ = cancellation_token.cancelled() => {
error_tx.send(CompletionResult { res: Ok(()) , name }).await
}
res = handle => {
let res = match res {
Ok(res) => res,
Err(join) => {
match join.source() {
Some(error) => {
Err(MadError::RunError{run: anyhow::anyhow!("component aborted: {:?}", error)})
},
None => {
if join.is_panic(){
Err(MadError::RunError { run: anyhow::anyhow!("component panicked: {}", join) })
} else {
Err(MadError::RunError { run: anyhow::anyhow!("component faced unknown error: {}", join) })
}
},
}
},
};
res = comp.run(job_cancellation) => {
error_tx.send(CompletionResult { res , name }).await
}
}
@@ -840,13 +818,13 @@ mod tests {
fn test_aggregate_error_display() {
let error1 = MadError::Inner(
anyhow::anyhow!("database connection failed")
.context("failed to connect to PostgreSQL"),
.context("failed to connect to PostgreSQL")
);
let error2 = MadError::Inner(
anyhow::anyhow!("port already in use")
.context("failed to bind to port 8080")
.context("web server initialization failed"),
.context("web server initialization failed")
);
let aggregate = MadError::AggregateError(AggregateError {
@@ -886,7 +864,7 @@ mod tests {
let error = MadError::Inner(
anyhow::anyhow!("root cause")
.context("middle layer")
.context("top layer"),
.context("top layer")
);
// Test that we can access the error chain

View File

@@ -138,30 +138,6 @@ async fn test_can_shutdown_gracefully() -> anyhow::Result<()> {
Ok(())
}
#[tokio::test]
#[traced_test]
async fn test_component_panics_shutdowns_cleanly() -> anyhow::Result<()> {
let res = Mad::builder()
.add_fn({
move |_cancel| async move {
panic!("my inner panic");
}
})
.add_fn(|cancel| async move {
cancel.cancelled().await;
Ok(())
})
.run()
.await;
let err_content = res.unwrap_err().to_string();
assert!(err_content.contains("component panicked"));
assert!(err_content.contains("my inner panic"));
Ok(())
}
#[test]
fn test_can_easily_transform_error() -> anyhow::Result<()> {
fn fallible() -> anyhow::Result<()> {