pub struct Error { /* private fields */ }
Expand description
Represents template errors.
If debug mode is enabled a template error contains additional debug
information that can be displayed by formatting an error with the
alternative formatting (format!("{:#}", err)
).
Example
Here is an example of you might want to render errors:
match template.render(ctx) {
Ok(result) => println!("{}", result),
Err(err) => {
eprintln!("Could not render template:");
eprintln!(" {:#}", err);
}
}
Implementations
sourceimpl Error
impl Error
sourcepub fn new<D: Into<Cow<'static, str>>>(kind: ErrorKind, detail: D) -> Error
pub fn new<D: Into<Cow<'static, str>>>(kind: ErrorKind, detail: D) -> Error
Creates a new error with kind and detail.
sourcepub fn with_source<E: Error + Send + Sync + 'static>(self, source: E) -> Self
pub fn with_source<E: Error + Send + Sync + 'static>(self, source: E) -> Self
Attaches another error as source to this error.
sourcepub fn debug_info(&self) -> Option<&DebugInfo>
This is supported on crate feature debug
only.
pub fn debug_info(&self) -> Option<&DebugInfo>
This is supported on crate feature
debug
only.Returns the template debug information is available.
The debug info snapshot is only embedded into the error if the debug
mode is enabled on the environment
(Environment::set_debug
).
Trait Implementations
sourceimpl Error for Error
impl Error for Error
sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
🔬 This is a nightly-only experimental API. (
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
👎 Deprecated since 1.42.0:
use the Display impl or to_string()
impl Eq for Error
Auto Trait Implementations
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more