forked from credebl/agent-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.ts
More file actions
114 lines (99 loc) · 2.53 KB
/
Copy patherrors.ts
File metadata and controls
114 lines (99 loc) · 2.53 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
103
104
105
106
107
108
109
110
111
112
113
114
class BaseError extends Error {
public statusCode: number
public constructor(message: string, statusCode: number) {
super(message)
this.name = this.constructor.name
this.statusCode = statusCode
Error.captureStackTrace(this, this.constructor)
}
}
class InternalServerError extends BaseError {
public constructor(message: string = 'Internal Server Error') {
super(message, 500)
}
}
class NotFoundError extends BaseError {
public constructor(message: string = 'Not Found') {
super(message, 404)
}
}
class BadRequestError extends BaseError {
public constructor(message: string = 'Bad Request') {
super(message, 400)
}
}
class UnauthorizedError extends BaseError {
public constructor(message: string = 'Unauthorized') {
super(message, 401)
}
}
class PaymentRequiredError extends BaseError {
public constructor(message: string = 'Payment Required') {
super(message, 402)
}
}
class ForbiddenError extends BaseError {
public constructor(message: string = 'Forbidden') {
super(message, 403)
}
}
class ConflictError extends BaseError {
public constructor(message: string = 'Conflict') {
super(message, 409)
}
}
class UnprocessableEntityError extends BaseError {
public constructor(message: string = 'Unprocessable Entity') {
super(message, 422)
}
}
class LedgerNotFoundError extends NotFoundError {
public constructor(message: string = 'Ledger Not Found') {
super(message)
}
}
class LedgerInvalidTransactionError extends BadRequestError {
public constructor(message: string = 'Ledger Invalid Transaction') {
super(message)
}
}
class CommonInvalidStructureError extends BadRequestError {
public constructor(message: string = 'Common Invalid Structure') {
super(message)
}
}
class RecordDuplicateError extends ConflictError {
public constructor(message: string = 'RecordDuplicateError') {
super(message)
}
}
const errorMap: Record<string, new (message: string) => BaseError> = {
InternalServerError,
NotFoundError,
BadRequestError,
LedgerNotFoundError,
LedgerInvalidTransactionError,
CommonInvalidStructureError,
UnauthorizedError,
PaymentRequiredError,
ForbiddenError,
ConflictError,
RecordDuplicateError,
UnprocessableEntityError,
}
export {
InternalServerError,
NotFoundError,
BadRequestError,
LedgerNotFoundError,
LedgerInvalidTransactionError,
CommonInvalidStructureError,
UnauthorizedError,
PaymentRequiredError,
ForbiddenError,
ConflictError,
BaseError,
RecordDuplicateError,
UnprocessableEntityError,
errorMap,
}