Skip to main content

alpm_rs/
error.rs

1use std::error;
2use std::fmt;
3
4use crate::enums;
5
6#[derive(Debug)]
7pub struct AlpmError {
8    error_no: enums::ErrorNo,
9}
10
11impl AlpmError{
12    pub fn new(error_no: enums::ErrorNo) -> AlpmError{
13        AlpmError{
14            error_no: error_no,
15        }
16    }
17}
18
19impl fmt::Display for AlpmError {
20    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21        write!(f, "alpm_error({})", self.error_no as i32)
22    }
23}
24
25// This is important for other errors to wrap this one.
26impl error::Error for AlpmError {
27    fn description(&self) -> &str {
28        "Alpm error."
29    }
30
31    fn cause(&self) -> Option<&error::Error> {
32        None
33    }
34}