This repository was archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy patherrors.ts
More file actions
102 lines (90 loc) · 3.64 KB
/
errors.ts
File metadata and controls
102 lines (90 loc) · 3.64 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { NodeError, NodeErrorContext, Values } from "@connext/vector-types";
type ServerNodeErrorContext = NodeErrorContext & {
publicIdentifier: string;
params: any;
};
export class ServerNodeError extends NodeError {
static readonly type = "ServerNodeError";
static readonly reasons = {
BadRequest: "Problem with request",
ChainServiceNotFound: "Chain service not found",
ChannelNotFound: "Channel not found",
ClearStoreFailed: "Failed to clear store",
CommitmentNotFound: "Withdrawal commitment not found",
CommitmentSingleSigned: "Withdrawal commitment single-signed",
CreateNodeFailed: "Could not create node",
GetChannelFailed: "Failed to get channel from store",
NodeNotFound: "Node not found",
ProviderNotConfigured: "Provider not configured for chainId",
RegisterSubscriptionFailed: "Failed to register subscription",
StoreMethodFailed: "Failed to execute store method",
SubscriptionNotFound: "Subscription URL not found",
TransactionNotFound: "Transaction not found",
TransferNotFound: "Transfer not found",
Unauthorized: "Unauthorized",
UnexpectedError: "Unexpected server error",
} as const;
readonly context: ServerNodeErrorContext;
constructor(
public readonly msg: Values<typeof ServerNodeError.reasons>,
publicIdentifier: string,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
params: any,
context: any = {},
) {
super(msg, { params, publicIdentifier, ...context }, ServerNodeError.type);
}
}
type LockErrorContext = NodeErrorContext & {
lockName: string;
lockValue?: string;
};
export class ServerNodeLockError extends NodeError {
static readonly type = "ServerNodeLockError";
static readonly reasons = {
AcquireLockFailed: "Failed to acquire lock",
AcquireMessageFailed: "Could not send lock acquisition message",
FailedToReleaseLock: "Failed to release lock",
ReleaseMessageFailed: "Could not send lock release message",
SentMessageAcquisitionFailed: "Could not acquire lock value, despite lock messsage",
} as const;
readonly context: LockErrorContext;
constructor(
public readonly msg: Values<typeof ServerNodeLockError.reasons>,
lockName: string,
lockValue?: string,
context: any = {},
) {
super(msg, { ...context, lockName, lockValue }, ServerNodeLockError.type);
this.context = { lockName, lockValue, ...context };
}
}
type ResubmitWithdrawalErrorContext = {
channelAddress: string;
publicIdentifier: string;
transferId: string;
};
export class ResubmitWithdrawalError extends NodeError {
static readonly type = "ResubmitWithdrawalError";
static readonly reasons = {
ChainServiceNotFound: "Could not find chain service",
CouldNotCheckSubmissionStatus: "Failed to check withdrawal submission status onchain",
CouldNotGetChannels: "Failed to get channels from store",
CouldNotGetCommitments: "Failed to get unsubmitted withdrawals",
CouldNotGetGasPrice: "Failed to get mainnet gas price",
SavingCommitmentFailed: "Failed to save withdrawal commitment",
SubmissionFailed: "Failed to submit withdrawal onchain",
WithdrawalDefinitionNotFound: "Failed to retrieve withdrawal definition from registry",
} as const;
readonly context: ResubmitWithdrawalErrorContext;
constructor(
public readonly msg: Values<typeof ResubmitWithdrawalError.reasons>,
publicIdentifier: string,
channelAddress: string,
transferId: string,
context: any = {},
) {
super(msg, { channelAddress, publicIdentifier, transferId, ...context }, ServerNodeError.type);
this.context = { channelAddress, publicIdentifier, transferId, ...context };
}
}