-
Notifications
You must be signed in to change notification settings - Fork 4
/
errors.ts
60 lines (49 loc) · 1.38 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
/*!
* Copyright (c) 2009-2024 World Data Exchange Holdings Pty Limited (WDXH). All rights reserved.
*/
/**
* @module Errors
*/
import { ApiError } from "./types/api/api-error-response";
// tslint:disable:max-classes-per-file
/**
* Generic Error thrown by the SDK.
*/
class DigiMeSDKError extends Error {
public name = "DigiMeSDKError";
constructor(message: Error["message"]) {
super(message);
Error.captureStackTrace(this, this.constructor);
}
}
/**
* Thrown when an error response is received from digi.me API.
* Error field will be populated with the response from digi.me.
*/
class ServerError extends DigiMeSDKError {
public name = "DigiMeServerError";
public error?: ApiError;
constructor(message: Error["message"], error?: ApiError) {
super(message);
this.error = error;
}
}
/**
* Thrown if the current SDK or its version is invalid.
*/
class SDKInvalidError extends ServerError {
public name = "SDKInvalidError";
}
/**
* Thrown if the parameter passed in fails type check.
*/
class TypeValidationError extends DigiMeSDKError {
public name = "TypeValidationError";
}
/**
* Thrown if there was an error decrypting a file.
*/
class FileDecryptionError extends DigiMeSDKError {
public name = "FileDecryptionError";
}
export { DigiMeSDKError, SDKInvalidError, TypeValidationError, FileDecryptionError, ServerError };