-
Notifications
You must be signed in to change notification settings - Fork 9
/
errors.ts
84 lines (69 loc) · 1.5 KB
/
errors.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* The base error class of hpke-js.
*/
export class BaseError extends Error {
public constructor(e: unknown) {
let message: string;
if (e instanceof Error) {
message = e.message;
} else if (typeof e === "string") {
message = e;
} else {
message = "";
}
super(message);
this.name = this.constructor.name;
}
}
/**
* The base error class of hpke-js.
*/
export class HpkeError extends BaseError {}
/**
* Invalid parameter.
*/
export class InvalidParamError extends HpkeError {}
/**
* KEM input or output validation failure.
*/
export class ValidationError extends HpkeError {}
/**
* Public or private key serialization failure.
*/
export class SerializeError extends HpkeError {}
/**
* Public or private key deserialization failure.
*/
export class DeserializeError extends HpkeError {}
/**
* encap() failure.
*/
export class EncapError extends HpkeError {}
/**
* decap() failure.
*/
export class DecapError extends HpkeError {}
/**
* Secret export failure.
*/
export class ExportError extends HpkeError {}
/**
* seal() failure.
*/
export class SealError extends HpkeError {}
/**
* open() failure.
*/
export class OpenError extends HpkeError {}
/**
* Sequence number overflow on the encryption context.
*/
export class MessageLimitReachedError extends HpkeError {}
/**
* Key pair derivation failure.
*/
export class DeriveKeyPairError extends HpkeError {}
/**
* Not supported failure.
*/
export class NotSupportedError extends HpkeError {}