use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("claim missing: label = {label}")]
ClaimMissing { label: String },
#[error("Unsupported Assertion version")]
AssertionUnsupportedVersion,
#[error("assertion missing: url = {url}")]
AssertionMissing { url: String },
#[error("unable to encode assertion data")]
AssertionEncoding,
#[error(transparent)]
AssertionDecoding(#[from] crate::assertion::AssertionDecodeError),
#[error("assertion could not be redacted")]
AssertionInvalidRedaction,
#[error("could not find the assertion to redact")]
AssertionRedactionNotFound,
#[error("bad parameter: {0}")]
BadParam(String),
#[error("required feature missing")]
MissingFeature(String),
#[error("feature implementation incomplete")]
NotImplemented(String),
#[error("claim could not be converted to CBOR")]
ClaimEncoding,
#[error("claim could not be converted from CBOR")]
ClaimDecoding,
#[error("claim already signed, no further changes allowed")]
ClaimAlreadySigned,
#[error("attempt to add new claim without signing last claim")]
ClaimUnsigned,
#[error("missing signature box link")]
ClaimMissingSignatureBox,
#[error("identity required required with copyright assertion")]
ClaimMissingIdentity,
#[error("incompatible claim version")]
ClaimVersion,
#[error("invalid claim content")]
ClaimInvalidContent,
#[error("claim missing hard binding")]
ClaimMissingHardBinding,
#[error("claim contains self redactions")]
ClaimSelfRedact,
#[error("claim contains disallowed redactions")]
ClaimDisallowedRedaction,
#[error("update manifest is invalid")]
UpdateManifestInvalid,
#[error("more than one manifest store detected")]
TooManyManifestStores,
#[error("COSE Sign1 structure can not be parsed: {coset_error}")]
InvalidCoseSignature {
coset_error: coset::CoseError, },
#[error("COSE signature algorithm is not supported")]
CoseSignatureAlgorithmNotSupported,
#[error("COSE could not find verification key")]
CoseMissingKey,
#[error("could not find signing certificate chain in COSE signature")]
CoseX5ChainMissing,
#[error("COSE error parsing certificate")]
CoseInvalidCert,
#[error("COSE signature invalid")]
CoseSignature,
#[error("COSE verifier failure")]
CoseVerifier,
#[error("COSE certificate has expired")]
CoseCertExpiration,
#[error("COSE certificate has been revoked")]
CoseCertRevoked,
#[error("COSE certificate not trusted")]
CoseCertUntrusted,
#[error("COSE time stamp could not be parsed")]
CoseInvalidTimeStamp,
#[error("COSE time stamp had expired cert")]
CoseTimeStampValidity,
#[error("COSE time stamp does not match data")]
CoseTimeStampMismatch,
#[error("could not generate a trusted time stamp")]
CoseTimeStampGeneration,
#[error("COSE TimeStamp Authority failure")]
CoseTimeStampAuthority,
#[error("COSE Signature too big for JUMBF box")]
CoseSigboxTooSmall,
#[error("COSE Signer does not contain signing certificate")]
CoseNoCerts,
#[error("WASM verifier error")]
WasmVerifier,
#[error("WASM RSA-PSS key import error: {0}")]
WasmRsaKeyImport(String),
#[error("WASM RSA-PSS verification error")]
WasmRsaVerification,
#[error("WASM crypto key error")]
WasmKey,
#[error("WASM not called from window or worker global scope")]
WasmInvalidContext,
#[error("WASM could not load crypto library")]
WasmNoCrypto,
#[error("could not create valid JUMBF for claim")]
JumbfCreationError,
#[error("thread receive error")]
ThreadReceiveError,
#[error("no JUMBF data found")]
JumbfNotFound,
#[error("required JUMBF box not found")]
JumbfBoxNotFound,
#[error("could not fetch the remote manifest")]
RemoteManifestFetch(String),
#[error("must fetch remote manifests from url")]
RemoteManifestUrl(String),
#[error("stopped because of logged error")]
LogStop,
#[error("not found")]
NotFound,
#[error("type is unsupported")]
UnsupportedType,
#[error("embedding error")]
EmbeddingError,
#[error("ingredient file not found")]
IngredientNotFound,
#[error("file not found: {0}")]
FileNotFound(String),
#[error("resource not found: {0}")]
ResourceNotFound(String),
#[error("XMP read error")]
XmpReadError(String),
#[error("XMP write error")]
XmpWriteError(String),
#[error("XMP is not supported")]
XmpNotSupported,
#[error("C2PA provenance not found in XMP")]
ProvenanceMissing,
#[error("hash verification( {0} )")]
HashMismatch(String),
#[error("claim verification failure: {0}")]
ClaimVerification(String),
#[error("PDF read error")]
PdfReadError,
#[error(transparent)]
InvalidClaim(#[from] crate::store::InvalidClaimError),
#[error("asset could not be parsed: {0}")]
InvalidAsset(String),
#[error(transparent)]
JumbfParseError(#[from] crate::jumbf::boxes::JumbfParseError),
#[error("The Verifiable Content structure is not valid")]
VerifiableCredentialInvalid,
#[error("could not parse ECDSA signature")]
InvalidEcdsaSignature,
#[error("missing data box")]
MissingDataBox,
#[error("could not generate XML")]
XmlWriteError,
#[error("unknown algorithm")]
UnknownAlgorithm,
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
JsonError(#[from] serde_json::Error),
#[error(transparent)]
#[cfg(all(not(target_arch = "wasm32"), feature = "add_thumbnails"))]
ImageError(#[from] image::ImageError),
#[error(transparent)]
CborError(#[from] serde_cbor::Error),
#[error(transparent)]
#[cfg(feature = "openssl")]
OpenSslError(#[from] openssl::error::ErrorStack),
#[error(transparent)]
OtherError(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
#[error("prerelease content detected")]
PrereleaseError,
}
pub type Result<T> = std::result::Result<T, Error>;