1pub mod caller;
2pub use caller::Caller;
3
4pub trait Traceback: std::error::Error {
5 fn message(&self) -> String;
6 fn with(&self, caller: Caller) -> Self;
7 fn callers(&self) -> Vec<Caller>;
8
9 fn callers_to_string(&self, indent: usize) -> String {
10 let indentation = " ".repeat(indent).to_string();
11 self.callers()
12 .iter()
13 .enumerate()
14 .map(|(index, caller)| format!("{}{}", indentation.repeat(index), caller))
15 .collect::<Vec<String>>()
16 .join("\n")
17 }
18
19 fn highlight_message(&self) -> String {
20 format!("{}", self.message())
21 }
22 fn previous_as_debug(&self) -> String {
23 String::new()
24 }
25 fn previous_as_string(&self) -> String {
26 String::new()
27 }
28}