1
+ // Tbdex exception codes are each thrown in exactly one place.
2
+ // Each code is prefixed with the name of the file in which it is thrown.
3
+ enum TbdexExceptionCode {
4
+ parserKindRequired,
5
+ parserMessageJsonNotObject,
6
+ parserMetadataMalformed,
7
+ parserUnknownMessageKind,
8
+ parserUnknownResourceKind,
9
+ messageSignatureMissing,
10
+ messageSignatureMismatch,
11
+ messageUnknownKind,
12
+ resourceSignatureMissing,
13
+ resourceSignatureMismatch,
14
+ resourceUnknownKind,
15
+ rfqClaimsHashMismatch,
16
+ rfqClaimsMissing,
17
+ rfqOfferingIdMismatch,
18
+ rfqPrivateDataMissing,
19
+ rfqPayinDetailsHashMismatch,
20
+ rfqPayinDetailsMissing,
21
+ rfqPayinGreaterThanMax,
22
+ rfqPayinLessThanMin,
23
+ rfqPayinDetailsNotValid,
24
+ rfqPayoutDetailsHashMismatch,
25
+ rfqPayoutDetailsMissing,
26
+ rfqPayoutDetailsNotValid,
27
+ rfqProtocolVersionMismatch,
28
+ rfqUnknownPayinKind,
29
+ rfqUnknownPayoutKind,
30
+ validatorNoSchema,
31
+ validatorUnknownMessageKind,
32
+ validatorUnknownResourceKind,
33
+ validatorJsonSchemaError,
34
+ }
35
+
36
+ // TbdexException is the parent class for all custom exceptions thrown from this package
37
+ class TbdexException implements Exception {
38
+ final String message;
39
+ final TbdexExceptionCode code;
40
+ TbdexException (this .code, this .message);
41
+
42
+ @override
43
+ String toString () => 'TbdexException($code ): $message ' ;
44
+ }
45
+
46
+ class TbdexParseException extends TbdexException {
47
+ TbdexParseException (TbdexExceptionCode code, String message): super (code, message);
48
+ }
49
+
50
+ class TbdexSignatureVerificationException extends TbdexException {
51
+ TbdexSignatureVerificationException (TbdexExceptionCode code, String message): super (code, message);
52
+ }
53
+
54
+ class TbdexValidatorException extends TbdexException {
55
+ TbdexValidatorException (TbdexExceptionCode code, String message): super (code, message);
56
+ }
57
+
58
+ // Thrown when verifying RFQ against offering
59
+ class TbdexVerifyOfferingRequirementsException extends TbdexException {
60
+ TbdexVerifyOfferingRequirementsException (TbdexExceptionCode code, String message): super (code, message);
61
+ }
0 commit comments