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
42
use core::fmt;

#[derive(Debug, Clone)]
pub struct Error {
  pub details: String,
}

impl Error {
  pub fn new(details: String) -> Self {
    Self { details }
  }
}

impl fmt::Display for Error {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    write!(f, "{}", self.details)
  }
}

impl std::error::Error for Error {
  fn description(&self) -> &str {
    &self.details
  }
}

impl From<oauth2::url::ParseError> for Error {
  fn from(error: oauth2::url::ParseError) -> Self {
    Self::new(error.to_string())
  }
}

impl From<jsonwebtoken::errors::Error> for Error {
  fn from(error: jsonwebtoken::errors::Error) -> Self {
    Self::new(error.to_string())
  }
}

impl From<reqwest::Error> for Error {
  fn from(error: reqwest::Error) -> Self {
    Self::new(error.to_string())
  }
}