Skip to content

Commit

Permalink
refactor: swap to unwrap_or on get_next_time call
Browse files Browse the repository at this point in the history
  • Loading branch information
bconn98 committed Jul 10, 2024
1 parent 46b1779 commit 88e123e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/append/rolling_file/policy/compound/trigger/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,8 @@ impl TimeTrigger {

#[cfg(not(test))]
let current = Local::now();
let next_time = match TimeTrigger::get_next_time(current, config.interval, config.modulate)
{
Ok(next_time) => next_time,
Err(err) => panic!("{}", err),
};
// In the case where bad user input results in an invalid next time, provide a valid time.
let next_time = TimeTrigger::get_next_time(current, config.interval, config.modulate).unwrap_or(i64::MAX);
let next_roll_time = if config.max_random_delay > 0 {
let random_delay = rand::thread_rng().gen_range(0..config.max_random_delay);
// This is a valid unwrap because chrono::Duration::try_milliseconds accepts an i64
Expand Down

0 comments on commit 88e123e

Please sign in to comment.