1use dactyl::NiceU32;
6use std::fmt;
7
8
9
10#[derive(Debug, Clone, Copy)]
11pub enum BrunchError {
15 DupeName,
17
18 NoBench,
20
21 NoRun,
23
24 Overflow,
26
27 TooFast,
29
30 TooSmall(u32),
32
33 TooWild,
35}
36
37impl std::error::Error for BrunchError {}
38
39impl fmt::Display for BrunchError {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 match self {
42 Self::DupeName => f.write_str("Benchmark names must be unique."),
43 Self::NoBench => f.write_str("At least one benchmark is required."),
44 Self::NoRun => f.write_str("Missing \x1b[1;96mBench::run\x1b[0m."),
45 Self::Overflow => f.write_str("Unable to crunch the numbers."),
46 Self::TooFast => f.write_str("Too fast to benchmark!"),
47 Self::TooSmall(n) => write!(
48 f, "Insufficient samples collected ({}); try increasing the timeout.",
49 NiceU32::from(*n),
50 ),
51 Self::TooWild => f.write_str("Samples too wild to analyze."),
52 }
53 }
54}