Skip to content
Myr

error.rs

This file

Path

src/error.rs

66 lines · 2.6 KiB · Rust

Last changed by

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

History of this file

Take it

1use std::num::{self, ParseFloatError, ParseIntError};23use rust_decimal::Error as DecimalError;4use thiserror::Error;56#[derive(Debug, Error)]7#[error(transparent)]8pub struct ConsoleOutputError(pub std::io::Error);910#[derive(Debug, Error)]11pub enum ParameterScanError {12    #[error("Error while parsing parameter scan arguments ({0})")]13    ParseIntError(num::ParseIntError),14    #[error("Error while parsing parameter scan arguments ({0})")]15    ParseDecimalError(DecimalError),16    #[error("Empty parameter range")]17    EmptyRange,18    #[error("Parameter range is too large")]19    TooLarge,20    #[error("Zero is not a valid parameter step")]21    ZeroStep,22    #[error("Parameter step size must be positive")]23    NegativeStep,24    #[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")]25    StepRequired,26    #[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")]27    UnexpectedCommandNameCount(usize, usize),28}2930impl From<num::ParseIntError> for ParameterScanError {31    fn from(e: num::ParseIntError) -> ParameterScanError {32        ParameterScanError::ParseIntError(e)33    }34}3536impl From<DecimalError> for ParameterScanError {37    fn from(e: DecimalError) -> ParameterScanError {38        ParameterScanError::ParseDecimalError(e)39    }40}4142#[derive(Debug, Error)]43pub enum OptionsError<'a> {44    #[error("{0}")]45    InvalidMetrics(String),46    #[error(47        "Conflicting requirements for the number of runs (empty range, min is larger than max)"48    )]49    EmptyRunsRange,50    #[error("Too many --command-name options: Expected {0} at most")]51    TooManyCommandNames(usize),52    #[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")]53    UnexpectedCommandNameCount(usize, usize),54    #[error("Could not read numeric integer argument to '--{0}': {1}")]55    IntParsingError(&'a str, ParseIntError),56    #[error("Could not read numeric floating point argument to '--{0}': {1}")]57    FloatParsingError(&'a str, ParseFloatError),58    #[error("An empty command has been specified for the '--shell <command>' option")]59    EmptyShell,60    #[error("Failed to parse '--shell <command>' expression as command line: {0}")]61    ShellParseError(shell_words::ParseError),62    #[error("Unknown output policy '{0}'. Use './{0}' to output to a file named '{0}'.")]63    UnknownOutputPolicy(String),64    #[error("The file '{0}' specified as '--input' does not exist")]65    StdinDataFileDoesNotExist(String),66}