Files
hyperfine/src/error.rs
T

64 lines
2.6 KiB
Rust
Raw Normal View History

use std::num::{self, ParseFloatError, 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;
#[derive(Debug, Error)]
#[error(transparent)]
pub struct ConsoleOutputError(pub std::io::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,
#[error("Parameter step size must be positive")]
NegativeStep,
2022-02-20 20:20:47 +01:00
#[error("A step size is required when the range bounds are floating point numbers. The step size can be specified with the '-D/--parameter-step-size <DELTA>' 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),
#[error("Could not read numeric integer argument to '--{0}': {1}")]
IntParsingError(&'a str, ParseIntError),
#[error("Could not read numeric floating point argument to '--{0}': {1}")]
FloatParsingError(&'a str, ParseFloatError),
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),
2022-05-17 14:21:16 -04:00
#[error("Unknown output policy '{0}'. Use './{0}' to output to a file named '{0}'.")]
UnknownOutputPolicy(String),
2023-03-15 09:12:14 +01:00
#[error("The file '{0}' specified as '--input' does not exist")]
2022-09-11 16:20:22 -05:00
StdinDataFileDoesNotExist(String),
}