Skip to content
Myr

error.rs

This file

Path

src/error.rs

62 lines · 2.5 KiB · Rust

Last changed by

Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834

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("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")]23    StepRequired,24    #[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")]25    UnexpectedCommandNameCount(usize, usize),26}2728impl From<num::ParseIntError> for ParameterScanError {29    fn from(e: num::ParseIntError) -> ParameterScanError {30        ParameterScanError::ParseIntError(e)31    }32}3334impl From<DecimalError> for ParameterScanError {35    fn from(e: DecimalError) -> ParameterScanError {36        ParameterScanError::ParseDecimalError(e)37    }38}3940#[derive(Debug, Error)]41pub enum OptionsError<'a> {42    #[error(43        "Conflicting requirements for the number of runs (empty range, min is larger than max)"44    )]45    EmptyRunsRange,46    #[error("Too many --command-name options: Expected {0} at most")]47    TooManyCommandNames(usize),48    #[error("'--command-name' has been specified {0} times. It has to appear exactly once, or exactly {1} times (number of benchmarks)")]49    UnexpectedCommandNameCount(usize, usize),50    #[error("Could not read numeric integer argument to '--{0}': {1}")]51    IntParsingError(&'a str, ParseIntError),52    #[error("Could not read numeric floating point argument to '--{0}': {1}")]53    FloatParsingError(&'a str, ParseFloatError),54    #[error("An empty command has been specified for the '--shell <command>' option")]55    EmptyShell,56    #[error("Failed to parse '--shell <command>' expression as command line: {0}")]57    ShellParseError(shell_words::ParseError),58    #[error("Unknown output policy '{0}'. Use './{0}' to output to a file named '{0}'.")]59    UnknownOutputPolicy(String),60    #[error("The file '{0}' specified as '--input' does not exist")]61    StdinDataFileDoesNotExist(String),62}