Skip to content

Commit eceaa89

Browse files
committed
fix(graph): graph does no longer panic when the given list of checks is empty
1 parent 0ca7861 commit eceaa89

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/analyze/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::outage::Severity;
1111

1212
pub fn draw_checks(checks: &[Check], file: impl AsRef<Path>) -> Result<(), AnalysisError> {
1313
if checks.is_empty() {
14-
panic!("need at least one check to draw the diagram");
14+
return Err(AnalysisError::NoChecksToAnalyze);
1515
}
1616
let outfile: &Path = file.as_ref();
1717
let mut data: Vec<(DateTime<Local>, Severity)> = Vec::new();

src/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,6 @@ pub enum AnalysisError {
195195
GraphDraw {
196196
reason: String, // plotters error type use generics, and that's just a pain
197197
},
198+
#[error("analysis was requested, but an empty list of checks was given")]
199+
NoChecksToAnalyze,
198200
}

0 commit comments

Comments
 (0)