pub enum Error {
UnsupportedSpec(FormatSpec),
ArgumentCountMismatch(usize, usize),
Parse(Box<Error<Rule>>),
}
Expand description
Errors that can occur during dynamic formatting.
This enum represents all possible errors that can occur during the parsing and application of format specifications.
Variants§
UnsupportedSpec(FormatSpec)
An unsupported format specification was encountered.
This error occurs when a format specification contains options or combinations that are not supported by the formatting machinery.
ArgumentCountMismatch(usize, usize)
The number of arguments doesn’t match the number of format specifications.
This error occurs when the number of arguments provided to a format string doesn’t match the number of format specifications in the string.
§Examples
Providing too few arguments:
use dyf::{FormatString, dformat, Error};
let fmt = FormatString::from_string("{}, {}".to_string()).unwrap();
let result = dformat!(&fmt, "only one argument");
assert!(matches!(result, Err(Error::ArgumentCountMismatch(2, 1))));
Providing too many arguments:
use dyf::{FormatString, dformat, Error};
let fmt = FormatString::from_string("{}".to_string()).unwrap();
let result = dformat!(&fmt, "one", "extra");
assert!(matches!(result, Err(Error::ArgumentCountMismatch(1, 2))));
Parse(Box<Error<Rule>>)
An error occurred during format string parsing.
This error wraps parsing errors from the underlying pest
parser and provides
information about syntax errors in format strings.