Skip to content

Commit

Permalink
error: Add RunnerApiError constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxFangX committed Apr 8, 2024
1 parent cd2a214 commit 5c81463
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions common/src/api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,26 @@ impl NodeApiError {
}
}

impl RunnerApiError {
pub fn at_capacity(error: impl fmt::Display) -> Self {
let kind = RunnerErrorKind::AtCapacity;
let msg = format!("{error:#}");
Self { kind, msg }
}

pub fn temporarily_unavailable(error: impl fmt::Display) -> Self {
let kind = RunnerErrorKind::TemporarilyUnavailable;
let msg = format!("{error:#}");
Self { kind, msg }
}

pub fn service_unavailable(error: impl fmt::Display) -> Self {
let kind = RunnerErrorKind::ServiceUnavailable;
let msg = format!("{error:#}");
Self { kind, msg }
}
}

// --- Test utils for asserting error invariants --- //

#[cfg(any(test, feature = "test-utils"))]
Expand Down

0 comments on commit 5c81463

Please sign in to comment.