Files
hyperfine/src/error.rs
T

53 lines
2.0 KiB
Rust
Raw Normal View History

2018-05-22 22:57:51 +02:00
use std::num;
use std::num::ParseIntError;
2021-08-24 21:33:48 +02:00
use rust_decimal::Error as DecimalError;
2022-02-06 11:59:21 +01:00
use thiserror::Error;
2022-02-06 11:59:21 +01:00
#[derive(Debug, Error)]
2018-03-24 20:17:17 +01:00
pub enum ParameterScanError {
2022-02-06 11:59:21 +01:00
#[error("Error while parsing parameter scan arguments ({0})")]
ParseIntError(num::ParseIntError),
2022-02-06 11:59:21 +01:00
#[error("Error while parsing parameter scan arguments ({0})")]
2019-08-31 12:48:26 +05:30
ParseDecimalError(DecimalError),
2022-02-06 11:59:21 +01:00
#[error("Empty parameter range")]
EmptyRange,
2022-02-06 11:59:21 +01:00
#[error("Parameter range is too large")]
TooLarge,
2022-02-06 11:59:21 +01:00
#[error("Zero is not a valid parameter step")]
ZeroStep,
2022-02-06 11:59:21 +01:00
#[error("A step size is required when the range bounds are floating point numbers. The step size can be specified with the '--parameter-step-size' parameter")]
2019-08-31 12:48:26 +05:30
StepRequired,
2022-02-06 11:59:21 +01:00
#[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")]
UnexpectedCommandNameCount(usize, usize),
}
2018-03-24 20:17:17 +01:00
impl From<num::ParseIntError> for ParameterScanError {
fn from(e: num::ParseIntError) -> ParameterScanError {
ParameterScanError::ParseIntError(e)
}
}
2019-08-31 12:48:26 +05:30
impl From<DecimalError> for ParameterScanError {
fn from(e: DecimalError) -> ParameterScanError {
ParameterScanError::ParseDecimalError(e)
}
}
2022-02-06 11:59:21 +01:00
#[derive(Debug, Error)]
pub enum OptionsError<'a> {
2022-02-06 11:59:21 +01:00
#[error(
"Conflicting requirements for the number of runs (empty range, min is larger than max)"
)]
EmptyRunsRange,
2022-02-06 11:59:21 +01:00
#[error("Too many --command-name options: Expected {0} at most")]
TooManyCommandNames(usize),
2022-02-06 11:59:21 +01:00
#[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")]
UnexpectedCommandNameCount(usize, usize),
2022-02-06 11:59:21 +01:00
#[error("Could not read numeric argument to '--{0}': {1}")]
NumericParsingError(&'a str, ParseIntError),
2022-02-06 11:59:21 +01:00
#[error("An empty command has been specified for the '--shell <command>' option")]
2021-10-04 22:34:19 +09:00
EmptyShell,
2022-02-06 11:59:21 +01:00
#[error("Failed to parse '--shell <command>' expression as command line: {0}")]
2021-10-04 22:34:19 +09:00
ShellParseError(shell_words::ParseError),
}