2018-05-22 22:57:51 +02:00
use std ::num ;
2020-10-16 23:38:15 +02:00
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 ;
2018-03-24 15:46:28 +01:00
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})" )]
2018-03-24 15:46:28 +01:00
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" )]
2018-03-24 15:46:28 +01:00
EmptyRange ,
2022-02-06 11:59:21 +01:00
#[error( "Parameter range is too large" )]
2018-03-24 15:46:28 +01:00
TooLarge ,
2022-02-06 11:59:21 +01:00
#[error( "Zero is not a valid parameter step" )]
2019-08-22 00:50:20 +05:30
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)" )]
2021-07-27 14:24:30 +00:00
UnexpectedCommandNameCount ( usize , usize ),
2018-03-24 15:46:28 +01:00
}
2018-03-24 20:17:17 +01:00
impl From < num ::ParseIntError > for ParameterScanError {
fn from ( e : num ::ParseIntError ) -> ParameterScanError {
ParameterScanError ::ParseIntError ( e )
2018-03-24 15:46:28 +01:00
}
}
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)]
2020-10-16 23:38:15 +02:00
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)"
)]
2018-09-09 14:10:36 +01:00
EmptyRunsRange ,
2022-02-06 11:59:21 +01:00
#[error( "Too many --command-name options: Expected {0} at most" )]
2020-10-15 22:32:30 +02:00
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)" )]
2021-07-27 14:24:30 +00:00
UnexpectedCommandNameCount ( usize , usize ),
2022-02-06 11:59:21 +01:00
#[error( "Could not read numeric argument to '--{0}': {1}" )]
2020-10-16 23:38:15 +02:00
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 ),
2018-09-09 14:10:36 +01:00
}