Skip to content

Commit

Permalink
[temp] Display and Error for ErrFromEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
belovdv committed Mar 14, 2023
1 parent 621665f commit 1cd2091
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,28 @@ pub enum ErrFromEnv {
},
}

impl std::fmt::Display for ErrFromEnv {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ErrFromEnv::IsNotConfigured => {
write!(f, "couldn't find relevant environment variable")
}
ErrFromEnv::PlatformSpecific { err, env, var } => {
write!(f, "{err} ({env}={var}")
}
}
}
}

impl std::error::Error for ErrFromEnv {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
ErrFromEnv::IsNotConfigured => None,
ErrFromEnv::PlatformSpecific { err, .. } => Some(err),
}
}
}

impl Client {
/// Creates a new jobserver initialized with the given parallelism limit.
///
Expand Down

0 comments on commit 1cd2091

Please sign in to comment.