-
-
Notifications
You must be signed in to change notification settings - Fork 381
/
Copy patherror.rs
54 lines (49 loc) · 2.15 KB
/
error.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::num::{self, ParseIntError};
use rust_decimal::Error as DecimalError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ParameterScanError {
#[error("Error while parsing parameter scan arguments ({0})")]
ParseIntError(num::ParseIntError),
#[error("Error while parsing parameter scan arguments ({0})")]
ParseDecimalError(DecimalError),
#[error("Empty parameter range")]
EmptyRange,
#[error("Parameter range is too large")]
TooLarge,
#[error("Zero is not a valid parameter step")]
ZeroStep,
#[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")]
StepRequired,
#[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")]
UnexpectedCommandNameCount(usize, usize),
}
impl From<num::ParseIntError> for ParameterScanError {
fn from(e: num::ParseIntError) -> ParameterScanError {
ParameterScanError::ParseIntError(e)
}
}
impl From<DecimalError> for ParameterScanError {
fn from(e: DecimalError) -> ParameterScanError {
ParameterScanError::ParseDecimalError(e)
}
}
#[derive(Debug, Error)]
pub enum OptionsError<'a> {
#[error(
"Conflicting requirements for the number of runs (empty range, min is larger than max)"
)]
EmptyRunsRange,
#[error("Too many --command-name options: Expected {0} at most")]
TooManyCommandNames(usize),
#[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 argument to '--{0}': {1}")]
NumericParsingError(&'a str, ParseIntError),
#[error("An empty command has been specified for the '--shell <command>' option")]
EmptyShell,
#[error("Failed to parse '--shell <command>' expression as command line: {0}")]
ShellParseError(shell_words::ParseError),
#[error("Unknown output policy '{0}'. Use './{0}' to output to a file named '{0}'.")]
UnknownOutputPolicy(String),
}