-
-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: panic on invalid time-style format #1240
Comments
I have traced this bug, this comes from chronos lib. It panics on invalid format do we need error handling on our side or should I raise PR on chronos lib itself. file: src/output/time.rs fn custom(time: &DateTime<FixedOffset>, non_recent_fmt: &str, recent_fmt: Option<&str>) -> String {
if let Some(recent_fmt) = recent_fmt {
if time.year() == *CURRENT_YEAR {
time.format(recent_fmt).to_string()
} else {
time.format(non_recent_fmt).to_string()
}
} else {
time.format(non_recent_fmt).to_string()
}
} |
However, we can just bypass x.to_string() let mut string = String::new();
if write!(&mut string, "{}", x).is_err() {
string = "Format error".to_owned();
}
string |
Validate --time-style format string during option parsing so we can give a good error message rather than let rayon handle the panic and give no context. Fixes: eza-community#1240
Validate --time-style format string during option parsing so we can give a good error message rather than let rayon handle the panic and give no context. Fixes: eza-community#1240
Validate --time-style format string during option parsing so we can give a good error message rather than let rayon handle the panic and give no context. Fixes: eza-community#1240
i think an error message instead of a panic, akin to
eza -l --time-style invalid
for example, would be more appropriate.The text was updated successfully, but these errors were encountered: