identity_iota_core/
error.rs

1// Copyright 2020-2023 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4/// Alias for a `Result` with the error type [`Error`].
5pub type Result<T, E = Error> = core::result::Result<T, E>;
6
7/// This type represents errors that can occur when constructing credentials and presentations or their serializations.
8#[derive(Debug, thiserror::Error, strum::IntoStaticStr)]
9#[non_exhaustive]
10pub enum Error {
11  /// Caused by a failure to serialize or deserialize.
12  #[error("serialization error: {0}")]
13  SerializationError(&'static str, #[source] Option<identity_core::Error>),
14  /// Caused by an invalid DID.
15  #[error("invalid did")]
16  DIDSyntaxError(#[source] identity_did::Error),
17  /// Caused by an invalid DID document.
18  #[error("invalid document")]
19  InvalidDoc(#[source] identity_document::Error),
20  /// Caused by a client failure during resolution.
21  #[error("DID resolution failed; {0}")]
22  DIDResolutionError(String),
23  /// Caused by an invalid network name.
24  #[error("\"{0}\" is not a valid network name in the context of the `iota` did method")]
25  InvalidNetworkName(String),
26  /// Caused by a mismatch of the DID's network and the network the client is connected with.
27  #[error("unable to resolve a `{expected}` DID on network `{actual}`")]
28  NetworkMismatch {
29    /// The network of the DID.
30    expected: String,
31    /// The network the client is connected with.
32    actual: String,
33  },
34  /// Caused by an attempt to read state metadata that does not adhere to the IOTA DID method specification.
35  #[error("invalid state metadata {0}")]
36  InvalidStateMetadata(&'static str),
37  #[cfg(feature = "revocation-bitmap")]
38  /// Caused by a failure during (un)revocation of credentials.
39  #[error("credential revocation error")]
40  RevocationError(#[source] identity_credential::revocation::RevocationError),
41  /// Caused by an error when constructing an output id.
42  #[error("conversion to an OutputId failed: {0}")]
43  OutputIdConversionError(String),
44  #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
45  /// Caused by an error in the Wasm bindings.
46  #[error("JavaScript function threw an exception: {0}")]
47  JsError(String),
48  /// Caused by an error during JSON Web Signature verification.
49  #[error("jws signature verification failed")]
50  JwsVerificationError(#[source] identity_document::Error),
51}