spdcalc/
exceptions.rs

1use std::error::Error;
2use std::fmt;
3
4/// Generic error type for the SPDCalc library
5#[derive(Debug, Clone)]
6pub struct SPDCError(pub String);
7
8impl fmt::Display for SPDCError {
9  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10    write!(f, "{}", self.0)
11  }
12}
13
14impl Error for SPDCError {
15  fn description(&self) -> &str {
16    &self.0
17  }
18}
19
20impl SPDCError {
21  /// Create a new SPDCError
22  pub fn new(message: String) -> Self {
23    Self(message)
24  }
25}