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