Skip to content

Commit

Permalink
[rust] Panic if JSON output is used but no entries are collected (Sel…
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia authored Nov 27, 2023
1 parent 2008e10 commit dde3eed
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rust/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use Color::{Blue, Cyan, Green, Red, Yellow};
pub const DRIVER_PATH: &str = "Driver path: ";
pub const BROWSER_PATH: &str = "Browser path: ";

#[derive(Default)]
#[derive(Default, PartialEq)]
enum OutputType {
#[default]
Logger,
Expand Down Expand Up @@ -219,6 +219,8 @@ impl Logger {
let json = json_output.deref();
if !json.logs.is_empty() {
print!("{}", serde_json::to_string_pretty(json).unwrap());
} else if self.output == OutputType::Json {
panic!("JSON output has been specified, but no entries have been collected")
}
}
}

0 comments on commit dde3eed

Please sign in to comment.