1 |
|
2 | interface IError {
|
3 | code: string;
|
4 | name: string;
|
5 | message: string;
|
6 | action: string
|
7 | }
|
8 |
|
9 | const errorsMap = [
|
10 |
|
11 | {
|
12 | code : '001',
|
13 | name : 'unauthorizedAccess',
|
14 | message: 'Unauthorized Access'
|
15 | },
|
16 | {
|
17 | code : '002',
|
18 | name : 'databaseError',
|
19 | message: 'Database error'
|
20 | },
|
21 | {
|
22 | code : '003',
|
23 | name : 'inputParameterIsInvalid',
|
24 | message: 'Input parameter is invalid'
|
25 | },
|
26 | {
|
27 | code : '004',
|
28 | name : 'systemError',
|
29 | message: 'System error'
|
30 | },
|
31 | {
|
32 | code : '005',
|
33 | name : 'invalidMerchantID',
|
34 | message: 'Invalid Merchant ID'
|
35 | }, {
|
36 | code : '006',
|
37 | name : 'invalidPlayerPIN',
|
38 | message: 'Invalid Player PIN'
|
39 | },
|
40 | {
|
41 | code : '007',
|
42 | name : 'unableToFindConnectionIdFromPaymentToken',
|
43 | message: 'Unable to find connection ID from Payment Token'
|
44 | },
|
45 | {
|
46 | code : '008',
|
47 | name : 'sessionTimedOut',
|
48 | message: 'Session timed out'
|
49 | },
|
50 | {
|
51 | code : '009',
|
52 | name : 'invalidStoreId',
|
53 | message: 'Invalid Store ID'
|
54 | },
|
55 | {
|
56 | code : '010',
|
57 | name : 'unableToProcessThePreAuthorization',
|
58 | message: 'Unable to process the Pre-Authorization'
|
59 | },
|
60 | {
|
61 | code : '011',
|
62 | name : 'errorAtCreateAlias',
|
63 | message: 'Error at create alias'
|
64 | },
|
65 | {
|
66 | code : '012',
|
67 | name : 'invalidPlayerId',
|
68 | message: 'Invalid playerId'
|
69 | },
|
70 | {
|
71 | code : '013',
|
72 | name : 'ticketValidationError',
|
73 | message: 'The tickets validations has error(s)'
|
74 | },
|
75 | {
|
76 | code : '014',
|
77 | name : 'playerHasLiveToken',
|
78 | message: 'Player has LIVE token'
|
79 | },
|
80 |
|
81 |
|
82 | {
|
83 | code : '101',
|
84 | name : 'invalidCredentials',
|
85 | message: 'Invalid Credentials'
|
86 | },
|
87 | {
|
88 | code : '102',
|
89 | name : 'unableToGetAuthToken',
|
90 | message: 'Unable to get Auth Token'
|
91 | },
|
92 | {
|
93 | code : '103',
|
94 | name : 'accountLockedDueToSeveralUnsuccessfulLoginAttempts',
|
95 | message: 'Account locked due to several unsuccessful login attempts'
|
96 | },
|
97 | {
|
98 | code : '104',
|
99 | name : 'playerIsNotEnrolled',
|
100 | message: 'Player is not enrolled'
|
101 | },
|
102 | {
|
103 | code : '105',
|
104 | name : 'playerAccountIsNotActive',
|
105 | message: 'Player account is not active'
|
106 | }, {
|
107 | code : '106',
|
108 | name : 'unableToCancelTransaction',
|
109 | message: 'Unable to cancel transaction'
|
110 | },
|
111 | {
|
112 | code : '107',
|
113 | name : 'unableToConnectToBPPHost ',
|
114 | message: 'Unable to connect to BPP host'
|
115 | },
|
116 |
|
117 |
|
118 | {
|
119 | code : '201',
|
120 | name : 'invalidOrExpiredPaymentToken',
|
121 | message: 'Invalid or Expired Payment Token'
|
122 | },
|
123 | {
|
124 | code : '202',
|
125 | name : 'errorProcessingPaymentTransaction',
|
126 | message: 'Error processing payment transaction'
|
127 | },
|
128 | {
|
129 | code : '203',
|
130 | name : 'paymentTokenIsNotValidAtStoreMOPLocation',
|
131 | message: 'Payment Token is not valid at store MOP location'
|
132 | },
|
133 | {
|
134 | code : '204',
|
135 | name : 'amountDoesNotMatch',
|
136 | message: 'Amount does not match'
|
137 | },
|
138 | {
|
139 | code : '205',
|
140 | name : 'InsufficientFunds',
|
141 | message: 'Insufficient Funds'
|
142 | }, {
|
143 | code : '206',
|
144 | name : 'unableToCancelFundsAuthorization',
|
145 | message: 'Unable to cancel funds authorization'
|
146 | },
|
147 | {
|
148 | code : '207',
|
149 | name : 'wrongAmountValue',
|
150 | message: 'Wrong amount value'
|
151 | },
|
152 | {
|
153 | code : '208',
|
154 | name : 'paymentTransactionCouldNotBeCreated',
|
155 | message: 'The payment transaction could not be created. An Unknown error occurred'
|
156 | },
|
157 | {
|
158 | code : '209',
|
159 | name : 'invalidTransaction',
|
160 | message: 'Invalid Transaction'
|
161 | },
|
162 | {
|
163 | code : '210',
|
164 | name : 'errorsAtGetCreditCards',
|
165 | message: 'Getting the cards and bank info could not be retrieved'
|
166 | }
|
167 |
|
168 | ];
|
169 |
|
170 | export class Errors {
|
171 | private errorsMap: Array<any>;
|
172 |
|
173 | constructor() {
|
174 | this.errorsMap = errorsMap;
|
175 | }
|
176 |
|
177 | getErrorByName(name: string) {
|
178 |
|
179 | const respFilter = this.errorsMap.find(error => error.name === name);
|
180 |
|
181 | if (respFilter) {
|
182 | return respFilter;
|
183 | }
|
184 |
|
185 | return name;
|
186 |
|
187 | }
|
188 |
|
189 | }
|