1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::error::Error;
use std::fmt;
pub mod btf_index;
pub mod c_dumper;
pub mod relocator;
pub mod types;
#[derive(Debug)]
pub struct BtfError {
details: String,
}
impl BtfError {
pub fn new(msg: &str) -> BtfError {
BtfError {
details: msg.to_string(),
}
}
pub fn new_owned(msg: String) -> BtfError {
BtfError { details: msg }
}
}
impl fmt::Display for BtfError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.details)
}
}
impl Error for BtfError {
fn description(&self) -> &str {
&self.details
}
}
pub type BtfResult<T> = Result<T, Box<dyn Error>>;
pub fn btf_error<T>(msg: String) -> BtfResult<T> {
Err(Box::new(BtfError::new_owned(msg)))
}