use multibase::Error as MultibaseError;
use serde_json::Error as SerdeJSONError;
use serde_urlencoded::de::Error as SerdeUrlEncodedError;
use ssi_caips::caip10::{BlockchainAccountIdParseError, BlockchainAccountIdVerifyError};
use thiserror::Error;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("Key mismatch")]
KeyMismatch,
#[error("JWT key not found")]
MissingKey,
#[error("A verification method MUST NOT contain multiple verification material properties for the same material. (DID Core)")]
MultipleKeyMaterial,
#[error("Invalid DID URL")]
DIDURL,
#[error("Unable to dereference DID URL: {0}")]
DIDURLDereference(String),
#[error("Unexpected DID fragment")]
UnexpectedDIDFragment,
#[error("Invalid context")]
InvalidContext,
#[error("DID controller limit exceeded")]
ControllerLimit,
#[error("Missing context")]
MissingContext,
#[error("Missing document ID")]
MissingDocumentId,
#[error("Expected object")]
ExpectedObject,
#[error("Unsupported verification relationship")]
UnsupportedVerificationRelationship,
#[error("Resource not found")]
ResourceNotFound(String),
#[error("Expected string for publicKeyMultibase")]
ExpectedStringPublicKeyMultibase,
#[error("RepresentationNotSupported")]
RepresentationNotSupported,
#[error(transparent)]
Multibase(#[from] MultibaseError),
#[error(transparent)]
SerdeJSON(#[from] SerdeJSONError),
#[error(transparent)]
SerdeUrlEncoded(#[from] SerdeUrlEncodedError),
#[error(transparent)]
BlockchainAccountIdParse(#[from] BlockchainAccountIdParseError),
#[error(transparent)]
BlockchainAccountIdVerify(#[from] BlockchainAccountIdVerifyError),
#[error(transparent)]
FromHex(#[from] hex::FromHexError),
#[error(transparent)]
Base58(#[from] bs58::decode::Error),
#[error("Expected string beginning with '0x'")]
HexString,
#[error("Unable to resolve: {0}")]
UnableToResolve(String),
#[error(transparent)]
JWK(#[from] ssi_jwk::Error),
}
impl From<Error> for String {
fn from(err: Error) -> String {
err.to_string()
}
}