UNPKG

1.64 kBJavaScriptView Raw
1// can't just do InvalidStoreError extends Error
2// because of http://babeljs.io/docs/usage/caveats/#classes
3export function InvalidStoreError(reason, value) {
4 const message = `Store is invalid because ${reason}, ` +
5 `please stop the client, delete all data and start the client again`;
6 const instance = Reflect.construct(Error, [message]);
7 Reflect.setPrototypeOf(instance, Reflect.getPrototypeOf(this));
8 instance.reason = reason;
9 instance.value = value;
10 return instance;
11}
12
13InvalidStoreError.TOGGLED_LAZY_LOADING = "TOGGLED_LAZY_LOADING";
14
15InvalidStoreError.prototype = Object.create(Error.prototype, {
16 constructor: {
17 value: Error,
18 enumerable: false,
19 writable: true,
20 configurable: true,
21 },
22});
23Reflect.setPrototypeOf(InvalidStoreError, Error);
24
25
26export function InvalidCryptoStoreError(reason) {
27 const message = `Crypto store is invalid because ${reason}, ` +
28 `please stop the client, delete all data and start the client again`;
29 const instance = Reflect.construct(Error, [message]);
30 Reflect.setPrototypeOf(instance, Reflect.getPrototypeOf(this));
31 instance.reason = reason;
32 instance.name = 'InvalidCryptoStoreError';
33 return instance;
34}
35
36InvalidCryptoStoreError.TOO_NEW = "TOO_NEW";
37
38InvalidCryptoStoreError.prototype = Object.create(Error.prototype, {
39 constructor: {
40 value: Error,
41 enumerable: false,
42 writable: true,
43 configurable: true,
44 },
45});
46Reflect.setPrototypeOf(InvalidCryptoStoreError, Error);
47
48export class KeySignatureUploadError extends Error {
49 constructor(message, value) {
50 super(message);
51 this.value = value;
52 }
53}