error.rs
This file
Path
src/error.rs
52 lines · 2.0 KiB · Rust
Last changed by
Improve error messageDavid Peterbefore adoptiond3c7c79
History of this fileTake it
1use std::num::{self, ParseIntError};23use rust_decimal::Error as DecimalError;4use thiserror::Error;56#[derive(Debug, Error)]7pub enum ParameterScanError {8 #[error("Error while parsing parameter scan arguments ({0})")]9 ParseIntError(num::ParseIntError),10 #[error("Error while parsing parameter scan arguments ({0})")]11 ParseDecimalError(DecimalError),12 #[error("Empty parameter range")]13 EmptyRange,14 #[error("Parameter range is too large")]15 TooLarge,16 #[error("Zero is not a valid parameter step")]17 ZeroStep,18 #[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")]19 StepRequired,20 #[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")]21 UnexpectedCommandNameCount(usize, usize),22}2324impl From<num::ParseIntError> for ParameterScanError {25 fn from(e: num::ParseIntError) -> ParameterScanError {26 ParameterScanError::ParseIntError(e)27 }28}2930impl From<DecimalError> for ParameterScanError {31 fn from(e: DecimalError) -> ParameterScanError {32 ParameterScanError::ParseDecimalError(e)33 }34}3536#[derive(Debug, Error)]37pub enum OptionsError<'a> {38 #[error(39 "Conflicting requirements for the number of runs (empty range, min is larger than max)"40 )]41 EmptyRunsRange,42 #[error("Too many --command-name options: Expected {0} at most")]43 TooManyCommandNames(usize),44 #[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")]45 UnexpectedCommandNameCount(usize, usize),46 #[error("Could not read numeric argument to '--{0}': {1}")]47 NumericParsingError(&'a str, ParseIntError),48 #[error("An empty command has been specified for the '--shell <command>' option")]49 EmptyShell,50 #[error("Failed to parse '--shell <command>' expression as command line: {0}")]51 ShellParseError(shell_words::ParseError),52}