forked from ipfs-shipyard/js-crypto-key-composer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.js
75 lines (61 loc) · 2.1 KB
/
errors.js
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
import ExtendableError from 'es6-error';
class BaseError extends ExtendableError {
constructor(message, name, code, props) {
super(message);
this.name = name || 'BaseError';
if (code) {
this.code = code;
}
Object.assign(this, props);
}
}
export class UnexpectedTypeError extends BaseError {
constructor(message, props) {
super(message, 'UnexpectedTypeError', 'UNEXPECTED_TYPE', props);
}
}
export class AggregatedError extends BaseError {
constructor(message, errors, props) {
super(message, 'AggregatedError', 'AGGREGATED_ERROR', { ...props, errors });
}
}
export class UnsupportedFormatError extends BaseError {
constructor(format, props) {
super(`Unsupported format '${format}'`, 'UnsupportedFormatError', 'UNSUPPORTED_FORMAT', props);
}
}
export class UnsupportedAlgorithmError extends BaseError {
constructor(message, props) {
super(message, 'UnsupportedAlgorithmError', 'UNSUPPORTED_ALGORITHM', props);
}
}
export class MissingPasswordError extends BaseError {
constructor(message, props) {
super(message, 'MissingPasswordError', 'MISSING_PASSWORD', props);
}
}
export class DecryptionFailedError extends BaseError {
constructor(message, props) {
super(message, 'DecryptionFailedError', 'DECRYPTION_FAILED', props);
}
}
export class DecodeAsn1FailedError extends BaseError {
constructor(message, modelName, props) {
super(message, 'DecodeAsn1FailedError', 'DECODE_ASN1_FAILED', { ...props, modelName });
}
}
export class EncodeAsn1FailedError extends BaseError {
constructor(message, modelName, props) {
super(message, 'EncodeAsn1FailedError', 'ENCODE_ASN1_FAILED', { ...props, modelName });
}
}
export class DecodePemFailedError extends BaseError {
constructor(message, props) {
super(message, 'DecodePemFailedError', 'DECODE_PEM_FAILED', props);
}
}
export class EncodePemFailedError extends BaseError {
constructor(message, props) {
super(message, 'EncodePemFailedError', 'ENCODE_PEM_FAILED', props);
}
}