-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Error into DecodeError and EncodeError
- Loading branch information
1 parent
81d4022
commit b720817
Showing
6 changed files
with
97 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#[derive(thiserror::Error, Debug)] | ||
pub enum DecodeError { | ||
#[error("Unable to deserialize string format of concatenated tildes")] | ||
UnableToDeserializeStringFormat, | ||
#[error("JWT is missing _sd_alg property")] | ||
MissingSdAlg, | ||
#[error("Unknown value of _sd_alg {0}")] | ||
UnknownSdAlg(String), | ||
#[error("Multiple disclosures given with the same hash")] | ||
MultipleDisclosuresWithSameHash, | ||
#[error("An _sd claim wasn't a string")] | ||
SdClaimNotString, | ||
#[error("And _sd property was not an array type")] | ||
SdPropertyNotArray, | ||
#[error("A disclosure claim would collid with an existing JWT claim")] | ||
DisclosureClaimCollidesWithJwtClaim, | ||
#[error("A disclosure is malformed")] | ||
DisclosureMalformed, | ||
#[error("A single disclosure was used multiple times")] | ||
DisclosureUsedMultipleTimes, | ||
#[error("Found an array item disclosure when expecting a property type")] | ||
ArrayDisclosureWhenExpectingProperty, | ||
#[error("Found a property type disclosure when expecting an array item")] | ||
PropertyDisclosureWhenExpectingArray, | ||
#[error("A disclosure was not used during decoding")] | ||
UnusedDisclosure, | ||
#[error(transparent)] | ||
JWS(#[from] ssi_jws::Error), | ||
#[error(transparent)] | ||
JsonDeserialization(#[from] serde_json::Error), | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum EncodeError { | ||
#[error("The base claims to encode did not become a JSON object")] | ||
EncodedAsNonObject, | ||
#[error("The base claims to encode contained a property reserved by SD-JWT")] | ||
EncodedClaimsContainsReservedProperty, | ||
#[error("A property for an array sd claim was not an array")] | ||
ExpectedArray, | ||
#[error("A disclosure was not used during decoding")] | ||
UnusedDisclosure, | ||
#[error(transparent)] | ||
JWS(#[from] ssi_jws::Error), | ||
#[error(transparent)] | ||
JsonSerialization(#[from] serde_json::Error), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters