jsonprooftoken/
errors.rs

1// Copyright 2023 Fondazione LINKS
2
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6
7//     http://www.apache.org/licenses/LICENSE-2.0
8
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use thiserror::Error;
16
17#[derive(Error, Debug)]
18pub enum CustomError {
19    #[error("Error during generation of a proof")]
20    ProofGenerationError(String),
21
22    #[error("Error during verification of a proof")]
23    ProofVerificationError(String),
24
25    #[error("Error during creation of a JWK")]
26    JwkGenerationError(String),
27
28    #[error("Issued Jwp NOT valid")]
29    InvalidIssuedJwp,
30
31    #[error("Presented Jwp NOT valid")]
32    InvalidPresentedJwp,
33
34    #[error("Issued Proof verification failed!")]
35    InvalidIssuedProof,
36
37    #[error("Presented Proof verification failed!")]
38    InvalidPresentedProof,
39
40    #[error("Index out of bounds!")]
41    IndexOutOfBounds,
42
43    #[error("Incomplete Jwp build")]
44    IncompleteJwpBuild(IncompleteJwpBuild),
45
46    #[error("Error during JSON flattening process")]
47    FlatteningError,
48
49    #[error("Error during selective disclosure of an attribute")]
50    SelectiveDisclosureError,
51
52    #[error("Serialization failed")]
53    SerializationError,
54
55    #[error("Invalid JWK")]
56    InvalidJwk,
57
58    #[error("Curve is not supported")]
59    CurveNotSupported,
60}
61
62#[derive(Error, Debug)]
63pub enum IncompleteJwpBuild {
64    #[error("Issuer Header Not set!")]
65    NoIssuerHeader,
66
67    #[error("Presentation Header Not set!")]
68    NoPresentationHeader,
69
70    #[error("Claims and Payloads Not set!")]
71    NoClaimsAndPayloads,
72
73    #[error("JWK Not set! Cannot generate a JWP!")]
74    NoJwk,
75}