Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: impl Error for WaitError #629

Merged
merged 2 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions testcontainers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ serde_with = "3.7.0"
signal-hook = { version = "0.3", optional = true }
tokio = { version = "1", features = ["macros", "fs", "rt-multi-thread"] }
tokio-util = "0.7.10"
thiserror = "1.0.60"
url = { version = "2", features = ["serde"] }

[features]
Expand Down
8 changes: 5 additions & 3 deletions testcontainers/src/core/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ fn end_of_stream(expected_msg: &str, lines: Vec<String>) -> WaitError {
}

/// Defines error cases when waiting for a message in a stream.
#[derive(Debug)]
#[derive(Debug, thiserror::Error)]
pub enum WaitError {
/// Indicates the stream ended before finding the log line you were looking for.
/// Contains all the lines that were read for debugging purposes.
EndOfStream(#[allow(dead_code)] Vec<String>), // todo: tuple is used by Debug impl, remove once nightly clippy is fixed
Io(#[allow(dead_code)] io::Error),
#[error("End of stream reached: {0:?}")]
EndOfStream(Vec<String>),
#[error(transparent)]
Io(io::Error),
}

impl From<io::Error> for WaitError {
Expand Down
Loading