Skip to content
Snippets Groups Projects
Verified Commit daf0bcf1 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: support for trace error

parent 6fb82460
Branches
Tags
No related merge requests found
Pipeline #4928 passed
......@@ -4,6 +4,7 @@
//! errors that can occur within Boytacean domain.
use std::{
backtrace::Backtrace,
error,
fmt::{self, Display, Formatter},
io,
......@@ -87,3 +88,28 @@ impl From<Error> for String {
error.description()
}
}
#[derive(Debug)]
pub struct TraceError {
error: Error,
backtrace: Backtrace,
}
impl TraceError {
pub fn new(error: Error) -> Self {
Self {
error,
backtrace: Backtrace::capture(),
}
}
pub fn backtrace(&self) -> Option<&Backtrace> {
Some(&self.backtrace)
}
}
impl Display for TraceError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.error.description())
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment