sd_jwt_rs/
error.rs

1// Copyright (c) 2024 DSR Corporation, Denver, Colorado.
2// https://www.dsr-corporation.com
3// SPDX-License-Identifier: Apache-2.0
4
5pub type Result<T> = ::core::result::Result<T, Error>;
6
7#[derive(Debug, thiserror::Error, strum::IntoStaticStr)]
8#[non_exhaustive]
9pub enum Error {
10    #[error("conversion error: Cannot convert to {0}")]
11    ConversionError(String),
12
13    #[error("invalid input: {0}")]
14    DeserializationError(String),
15
16    #[error("data field is not expected: {0}")]
17    DataFieldMismatch(String),
18
19    #[error("Digest {0} appears multiple times")]
20    DuplicateDigestError(String),
21
22    #[error("Key {0} appears multiple times")]
23    DuplicateKeyError(String),
24
25    #[error("invalid disclosure: {0}")]
26    InvalidDisclosure(String),
27
28    #[error("invalid array disclosure: {0}")]
29    InvalidArrayDisclosureObject(String),
30
31    #[error("invalid path: {0}")]
32    InvalidPath(String),
33
34    #[error("index {idx} is out of bounds for the provided array with length {length}: {msg}")]
35    IndexOutOfBounds {
36        idx: usize,
37        length: usize,
38        msg: String,
39    },
40
41    #[error("invalid state: {0}")]
42    InvalidState(String),
43
44    #[error("invalid input: {0}")]
45    InvalidInput(String),
46
47    #[error("key not found: {0}")]
48    KeyNotFound(String),
49
50    #[error("{0}")]
51    Unspecified(String),
52}