1use thiserror::Error;
2
3pub type Result<T> = core::result::Result<T, FormatError>;
4
5#[derive(Error, Debug, PartialEq)]
6pub enum FormatError {
7 #[error("Format error: {0}")]
8 FmtError(#[from] std::fmt::Error),
9 #[error("Unescaped opening brace without closing brace, at index {0} in '{1}'")]
10 UnmatchedOpeningBrace(usize, String),
11 #[error("Unescaped closing brace without opening brace, at index {0} in '{1}'")]
12 UnmatchedClosingBrace(usize, String),
13 #[error("Requested more parameters than provided!")]
14 NotEnoughParameters,
15 #[error("Positional parameter requested ({0}) but not provided")]
16 NoPositionalParameter(usize),
17 #[error("Named parameter requested ({0}) but not provided")]
18 NoNamedParameter(String),
19 #[error("Failed to parse integer: {0}")]
20 InvalidInteger(#[from] core::num::ParseIntError),
21 #[error("Invalid format spec, expected format type in '{full}', found: '{substr}'")]
22 InvalidFormatSpec { full: String, substr: String },
23 #[error("Unsupported format type: '{0}'")]
24 UnsupportedFormatType(String),
25 #[error("Expected precision after `.`, got: '{0}'")]
26 ExpectedPrecision(String),
27 #[error("Parameter passed as precision is not of type usize")]
28 PrecisionNotUsize,
29 #[error("Parameter passed as width is not of type usize")]
30 WidthNotUsize,
31 #[error("Parameter {0} does not implement trait {1}")]
32 TraitNotImplemented(String, &'static str),
33 #[error("Custom formatter error: {0}")]
34 Custom(String),
35}