identity_resolver/
error.rs1pub type Result<T, E = Error> = core::result::Result<T, E>;
6
7#[derive(Debug)]
11pub struct Error {
12 error_cause: ErrorCause,
13}
14
15impl Error {
16 pub(crate) fn new(cause: ErrorCause) -> Self {
17 Self { error_cause: cause }
18 }
19
20 pub fn error_cause(&self) -> &ErrorCause {
22 &self.error_cause
23 }
24
25 pub fn into_error_cause(self) -> ErrorCause {
27 self.error_cause
28 }
29}
30
31impl std::fmt::Display for Error {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 write!(f, "{}", self.error_cause)
34 }
35}
36
37impl std::error::Error for Error {
38 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
39 self.error_cause.source()
40 }
41}
42
43#[derive(Debug, thiserror::Error, strum::IntoStaticStr)]
47#[non_exhaustive]
48pub enum ErrorCause {
49 #[error("did resolution failed: could not parse the given did")]
51 #[non_exhaustive]
52 DIDParsingError {
53 source: Box<dyn std::error::Error + Send + Sync + 'static>,
55 },
56 #[error("did resolution failed: the attached handler failed")]
59 #[non_exhaustive]
60 HandlerError {
61 source: Box<dyn std::error::Error + Send + Sync + 'static>,
63 },
64 #[error("did resolution failed: the DID method \"{method}\" is not supported by the resolver")]
67 UnsupportedMethodError {
68 method: String,
70 },
71 #[error("none of the attached clients support the network {0}")]
73 UnsupportedNetwork(String),
74}