pub enum Error {
InvalidEscapeSequence(InvalidEscapeSequence),
MissingVariableName(MissingVariableName),
UnexpectedCharacter(UnexpectedCharacter),
MissingClosingBrace(MissingClosingBrace),
NoSuchVariable(NoSuchVariable),
}
Expand description
An error that can occur during variable substitution.
Variants§
InvalidEscapeSequence(InvalidEscapeSequence)
The input string contains an invalid escape sequence.
MissingVariableName(MissingVariableName)
The input string contains a variable placeholder without a variable name ("${}"
).
UnexpectedCharacter(UnexpectedCharacter)
The input string contains an unexpected character.
MissingClosingBrace(MissingClosingBrace)
The input string contains an unclosed variable placeholder.
NoSuchVariable(NoSuchVariable)
The input string contains a placeholder for a variable that is not in the variable map.
Implementations§
source§impl Error
impl Error
sourcepub fn source_range(&self) -> Range<usize>
pub fn source_range(&self) -> Range<usize>
Get the range in the source text that contains the error.
sourcepub fn source_line<'a>(&self, source: &'a str) -> &'a str
pub fn source_line<'a>(&self, source: &'a str) -> &'a str
Get the line of source that contains the error.
Panics
May panic if the source text is not the original source that contains the error.
sourcepub fn write_source_highlighting(
&self,
f: &mut impl Write,
source: &str
) -> Result
pub fn write_source_highlighting( &self, f: &mut impl Write, source: &str ) -> Result
Write source highlighting for the error location.
The highlighting ends with a newline.
Note: this function doesn’t print anything if the source line exceeds 60 characters in width.
For more control over this behaviour, consider using Self::source_range()
and Self::source_line()
instead.
sourcepub fn source_highlighting(&self, source: &str) -> String
pub fn source_highlighting(&self, source: &str) -> String
Get source highlighting for the error location as a string.
The highlighting ends with a newline.
Note: this function returns an empty string if the source line exceeds 60 characters in width.