vc-error-handlers 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/shared/constants/api-config.constants.mjs +43 -0
- package/esm2020/lib/shared/interceptors/http.interceptor.mjs +5 -18
- package/esm2020/lib/shared/services/global-error.service.mjs +115 -5
- package/esm2020/lib/shared/services/util.service.mjs +21 -0
- package/esm2020/lib/vc-error-handlers.component.mjs +10 -3
- package/fesm2015/vc-error-handlers.mjs +314 -152
- package/fesm2015/vc-error-handlers.mjs.map +1 -1
- package/fesm2020/vc-error-handlers.mjs +313 -152
- package/fesm2020/vc-error-handlers.mjs.map +1 -1
- package/lib/shared/constants/api-config.constants.d.ts +19 -0
- package/lib/shared/interceptors/http.interceptor.d.ts +1 -4
- package/lib/shared/services/global-error.service.d.ts +20 -1
- package/lib/shared/services/util.service.d.ts +6 -0
- package/lib/vc-error-handlers.component.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, Component, Input, Directive, ViewChild, NgModule, Optional, InjectionToken, ErrorHandler } from '@angular/core';
|
|
3
3
|
import { Subject, throwError } from 'rxjs';
|
|
4
|
+
import * as i3 from '@angular/router';
|
|
5
|
+
import { NavigationStart, NavigationEnd, NavigationError } from '@angular/router';
|
|
4
6
|
import * as i1 from '@vcomply/authorizer';
|
|
5
7
|
import * as i2 from '@angular/common';
|
|
6
8
|
import { CommonModule } from '@angular/common';
|
|
7
|
-
import * as i3 from '@angular/router';
|
|
8
|
-
import { NavigationStart, NavigationEnd, NavigationError } from '@angular/router';
|
|
9
9
|
import { HttpResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
10
10
|
import * as Sentry from '@sentry/angular-ivy';
|
|
11
11
|
import { timeout, tap, catchError } from 'rxjs/operators';
|
|
@@ -38,71 +38,6 @@ var ErrorStatusCode;
|
|
|
38
38
|
ErrorStatusCode[ErrorStatusCode["JSChunkUnavailable"] = 600] = "JSChunkUnavailable";
|
|
39
39
|
})(ErrorStatusCode || (ErrorStatusCode = {}));
|
|
40
40
|
|
|
41
|
-
class GlobalErrorService {
|
|
42
|
-
constructor() {
|
|
43
|
-
this.globalError$ = new Subject();
|
|
44
|
-
this.localError$ = new Subject();
|
|
45
|
-
}
|
|
46
|
-
handleError(error, request) {
|
|
47
|
-
if (this.isUnauthenticated(error) ||
|
|
48
|
-
this.isUnauthorizedAccess(error) ||
|
|
49
|
-
this.isNetworkUnavailable(error)) {
|
|
50
|
-
this.globalError$.next(error);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
isUnauthenticated(error) {
|
|
54
|
-
return error.status === ErrorStatusCode.Unauthenticated;
|
|
55
|
-
}
|
|
56
|
-
isUnauthorizedAccess(error) {
|
|
57
|
-
return error.status === ErrorStatusCode.UnauthorizedAccess;
|
|
58
|
-
}
|
|
59
|
-
isNetworkUnavailable(error) {
|
|
60
|
-
return error.status === ErrorStatusCode.NetworkUnavailable;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
GlobalErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
64
|
-
GlobalErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, providedIn: 'root' });
|
|
65
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, decorators: [{
|
|
66
|
-
type: Injectable,
|
|
67
|
-
args: [{
|
|
68
|
-
providedIn: 'root',
|
|
69
|
-
}]
|
|
70
|
-
}] });
|
|
71
|
-
|
|
72
|
-
class AuthService {
|
|
73
|
-
constructor(authorizer) {
|
|
74
|
-
this.authorizer = authorizer;
|
|
75
|
-
}
|
|
76
|
-
logoutUser() {
|
|
77
|
-
this.authorizer.logout();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, deps: [{ token: i1.AuthorizerService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
81
|
-
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, providedIn: "root" });
|
|
82
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, decorators: [{
|
|
83
|
-
type: Injectable,
|
|
84
|
-
args: [{
|
|
85
|
-
providedIn: "root",
|
|
86
|
-
}]
|
|
87
|
-
}], ctorParameters: function () { return [{ type: i1.AuthorizerService }]; } });
|
|
88
|
-
|
|
89
|
-
class RouterService {
|
|
90
|
-
redirectToLogin() {
|
|
91
|
-
window.location.href =
|
|
92
|
-
`https://${window.location.host}/` +
|
|
93
|
-
'signin?redirectURL=' +
|
|
94
|
-
encodeURIComponent(window.location.href);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
RouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
98
|
-
RouterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, providedIn: 'root' });
|
|
99
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, decorators: [{
|
|
100
|
-
type: Injectable,
|
|
101
|
-
args: [{
|
|
102
|
-
providedIn: 'root',
|
|
103
|
-
}]
|
|
104
|
-
}] });
|
|
105
|
-
|
|
106
41
|
const VCOMPLY_LOGO_URL = 'https://cdn.v-comply.com/logo/prod/v-logo.svg';
|
|
107
42
|
const API_TIMEOUT_TIME = 1000 * 15;
|
|
108
43
|
const ERROR_CONFIG = {
|
|
@@ -146,6 +81,49 @@ const ERROR_CONFIG = {
|
|
|
146
81
|
},
|
|
147
82
|
};
|
|
148
83
|
|
|
84
|
+
const PAGE_LEVEL_API_CONFIG = [
|
|
85
|
+
{
|
|
86
|
+
method: 'POST',
|
|
87
|
+
path: '/compliance_post',
|
|
88
|
+
query: { mode: 'xyz' },
|
|
89
|
+
body: { mode: 'abc' },
|
|
90
|
+
pageCodes: ['compliance:mr', 'risk:mr'],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
method: 'GET',
|
|
94
|
+
path: '/compliance_post',
|
|
95
|
+
query: { mode: 'xyz' },
|
|
96
|
+
body: { mode: 'abc' },
|
|
97
|
+
pageCodes: ['compliance:mr', 'risk:mr'],
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
const COMPONENT_LEVEL_API_CONFIG = [
|
|
101
|
+
{
|
|
102
|
+
method: 'GET',
|
|
103
|
+
path: '/organization/?mode=organisationUsersList',
|
|
104
|
+
query: { type: 'active' },
|
|
105
|
+
body: null,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
method: 'GET',
|
|
109
|
+
path: '/organization/?mode=organisationUsersList',
|
|
110
|
+
query: { type: 'power_users' },
|
|
111
|
+
body: null,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
method: 'GET',
|
|
115
|
+
path: '/organization/?mode=organisationUsersList',
|
|
116
|
+
query: { type: 'light_users' },
|
|
117
|
+
body: null,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
method: 'GET',
|
|
121
|
+
path: '/organization/?mode=organisationUsersList',
|
|
122
|
+
query: { type: 'inactive' },
|
|
123
|
+
body: null,
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
|
|
149
127
|
class SnackBarService {
|
|
150
128
|
constructor() {
|
|
151
129
|
this.snackbarSubject = new Subject();
|
|
@@ -175,6 +153,195 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
175
153
|
}]
|
|
176
154
|
}], ctorParameters: function () { return []; } });
|
|
177
155
|
|
|
156
|
+
class UtilsService {
|
|
157
|
+
isJsonSubset(parentJson, subsetJson) {
|
|
158
|
+
for (let key in subsetJson) {
|
|
159
|
+
if (!parentJson.hasOwnProperty(key) || parentJson[key] !== subsetJson[key]) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
UtilsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: UtilsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
167
|
+
UtilsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: UtilsService, providedIn: 'root' });
|
|
168
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: UtilsService, decorators: [{
|
|
169
|
+
type: Injectable,
|
|
170
|
+
args: [{
|
|
171
|
+
providedIn: 'root',
|
|
172
|
+
}]
|
|
173
|
+
}] });
|
|
174
|
+
|
|
175
|
+
class GlobalErrorService {
|
|
176
|
+
constructor(snackBarService, utilService, router) {
|
|
177
|
+
this.snackBarService = snackBarService;
|
|
178
|
+
this.utilService = utilService;
|
|
179
|
+
this.router = router;
|
|
180
|
+
this.globalError$ = new Subject();
|
|
181
|
+
this.localError$ = new Subject();
|
|
182
|
+
this.pageLevelApiConfig = PAGE_LEVEL_API_CONFIG;
|
|
183
|
+
this.componentLevelApiConfig = COMPONENT_LEVEL_API_CONFIG;
|
|
184
|
+
}
|
|
185
|
+
handleSoftErrors(event) {
|
|
186
|
+
const xData = event.headers.get('X-Data');
|
|
187
|
+
if (xData) {
|
|
188
|
+
const parsedData = JSON.parse(xData);
|
|
189
|
+
const statusCode = parsedData.statusCode;
|
|
190
|
+
const statusMessage = parsedData.message;
|
|
191
|
+
if (statusCode && statusCode !== 0) {
|
|
192
|
+
this.snackBarService.show(statusMessage || 'Error occurred', 'error');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
handleError(error, request) {
|
|
197
|
+
if (this.isUnauthenticated(error) ||
|
|
198
|
+
this.isUnauthorizedAccess(error) ||
|
|
199
|
+
this.isNetworkUnavailable(error)) {
|
|
200
|
+
this.publishGlobalError(error);
|
|
201
|
+
}
|
|
202
|
+
else if (this.isServerError(error)) {
|
|
203
|
+
this.handleServerError(error, request);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
this.handleSoftErrors(error);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
isServerError(error) {
|
|
210
|
+
const serverErrorCodes = [
|
|
211
|
+
ErrorStatusCode.InternalServerError,
|
|
212
|
+
ErrorStatusCode.ServiceUnavailable,
|
|
213
|
+
ErrorStatusCode.BadGateway,
|
|
214
|
+
ErrorStatusCode.RequestTimeout,
|
|
215
|
+
];
|
|
216
|
+
return serverErrorCodes.includes(error.status);
|
|
217
|
+
}
|
|
218
|
+
isUnauthenticated(error) {
|
|
219
|
+
return error.status === ErrorStatusCode.Unauthenticated;
|
|
220
|
+
}
|
|
221
|
+
isUnauthorizedAccess(error) {
|
|
222
|
+
return error.status === ErrorStatusCode.UnauthorizedAccess;
|
|
223
|
+
}
|
|
224
|
+
isNetworkUnavailable(error) {
|
|
225
|
+
return error.status === ErrorStatusCode.NetworkUnavailable;
|
|
226
|
+
}
|
|
227
|
+
handleServerError(error, request) {
|
|
228
|
+
if (this.isPageLevelError(error, request)) {
|
|
229
|
+
this.publishGlobalError(error);
|
|
230
|
+
}
|
|
231
|
+
else if (this.isComponentLevelError(error, request)) {
|
|
232
|
+
this.publishLocalError(error, request);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
this.showServerSnackBarError();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
publishGlobalError(error) {
|
|
239
|
+
this.globalError$.next(error);
|
|
240
|
+
}
|
|
241
|
+
publishLocalError(error, request) {
|
|
242
|
+
this.localError$.next({ error, request });
|
|
243
|
+
}
|
|
244
|
+
showServerSnackBarError() {
|
|
245
|
+
const message = ERROR_CONFIG.SERVER_ERROR.snackBarMessage;
|
|
246
|
+
this.snackBarService.show(message, 'error');
|
|
247
|
+
}
|
|
248
|
+
isPageLevelError(error, request) {
|
|
249
|
+
const { method, path, query, body } = this.parseRequest(request);
|
|
250
|
+
const pageCode = this.getPageCode();
|
|
251
|
+
const isConfigMatched = this.pageLevelApiConfig.some((apiConfig) => {
|
|
252
|
+
if (apiConfig.method !== method)
|
|
253
|
+
return false;
|
|
254
|
+
if (apiConfig.path !== path)
|
|
255
|
+
return false;
|
|
256
|
+
const isQuerySubset = this.utilService.isJsonSubset(apiConfig.query, query);
|
|
257
|
+
if (!isQuerySubset)
|
|
258
|
+
return false;
|
|
259
|
+
const isBodyMatch = this.utilService.isJsonSubset(apiConfig.body, body);
|
|
260
|
+
if (!isBodyMatch)
|
|
261
|
+
return false;
|
|
262
|
+
return apiConfig.pageCodes.includes(pageCode);
|
|
263
|
+
});
|
|
264
|
+
return isConfigMatched;
|
|
265
|
+
}
|
|
266
|
+
isComponentLevelError(error, request) {
|
|
267
|
+
const { method, url: path, params, body } = request;
|
|
268
|
+
const query = {};
|
|
269
|
+
params.keys().forEach((key) => {
|
|
270
|
+
query[key] = params.get(key);
|
|
271
|
+
});
|
|
272
|
+
const isConfigFound = this.componentLevelApiConfig.some((apiConfig) => {
|
|
273
|
+
if (apiConfig.method !== method)
|
|
274
|
+
return false;
|
|
275
|
+
if (!path.includes(apiConfig.path))
|
|
276
|
+
return false;
|
|
277
|
+
const isQuerySubset = this.utilService.isJsonSubset(query, apiConfig.query);
|
|
278
|
+
if (!isQuerySubset)
|
|
279
|
+
return false;
|
|
280
|
+
if (apiConfig.body) {
|
|
281
|
+
const isBodyMatch = this.utilService.isJsonSubset(apiConfig.body, body);
|
|
282
|
+
if (!isBodyMatch)
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
return true;
|
|
286
|
+
});
|
|
287
|
+
return isConfigFound;
|
|
288
|
+
}
|
|
289
|
+
parseRequest(request) {
|
|
290
|
+
const { method, url: path, params, body } = request;
|
|
291
|
+
const query = {};
|
|
292
|
+
params.keys().forEach((key) => {
|
|
293
|
+
query[key] = params.get(key);
|
|
294
|
+
});
|
|
295
|
+
return { method, path, query, body };
|
|
296
|
+
}
|
|
297
|
+
getPageCode() {
|
|
298
|
+
const currentRoute = this.router.routerState.snapshot.root.firstChild;
|
|
299
|
+
return currentRoute?.data?.pageCode;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
GlobalErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, deps: [{ token: SnackBarService }, { token: UtilsService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
303
|
+
GlobalErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, providedIn: 'root' });
|
|
304
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, decorators: [{
|
|
305
|
+
type: Injectable,
|
|
306
|
+
args: [{
|
|
307
|
+
providedIn: 'root',
|
|
308
|
+
}]
|
|
309
|
+
}], ctorParameters: function () { return [{ type: SnackBarService }, { type: UtilsService }, { type: i3.Router }]; } });
|
|
310
|
+
|
|
311
|
+
class AuthService {
|
|
312
|
+
constructor(authorizer) {
|
|
313
|
+
this.authorizer = authorizer;
|
|
314
|
+
}
|
|
315
|
+
logoutUser() {
|
|
316
|
+
this.authorizer.logout();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, deps: [{ token: i1.AuthorizerService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
320
|
+
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, providedIn: "root" });
|
|
321
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, decorators: [{
|
|
322
|
+
type: Injectable,
|
|
323
|
+
args: [{
|
|
324
|
+
providedIn: "root",
|
|
325
|
+
}]
|
|
326
|
+
}], ctorParameters: function () { return [{ type: i1.AuthorizerService }]; } });
|
|
327
|
+
|
|
328
|
+
class RouterService {
|
|
329
|
+
redirectToLogin() {
|
|
330
|
+
window.location.href =
|
|
331
|
+
`https://${window.location.host}/` +
|
|
332
|
+
'signin?redirectURL=' +
|
|
333
|
+
encodeURIComponent(window.location.href);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
RouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
337
|
+
RouterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, providedIn: 'root' });
|
|
338
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, decorators: [{
|
|
339
|
+
type: Injectable,
|
|
340
|
+
args: [{
|
|
341
|
+
providedIn: 'root',
|
|
342
|
+
}]
|
|
343
|
+
}] });
|
|
344
|
+
|
|
178
345
|
class SnackBarComponent {
|
|
179
346
|
constructor(snackbarService) {
|
|
180
347
|
this.snackbarService = snackbarService;
|
|
@@ -597,6 +764,74 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
597
764
|
}]
|
|
598
765
|
}], ctorParameters: function () { return [{ type: DialogService }]; } });
|
|
599
766
|
|
|
767
|
+
class ServerErrorComponent {
|
|
768
|
+
constructor() {
|
|
769
|
+
this.errorConfig = ERROR_CONFIG.SERVER_ERROR;
|
|
770
|
+
this.VcomplyLogo = VCOMPLY_LOGO_URL;
|
|
771
|
+
}
|
|
772
|
+
refreshPage() {
|
|
773
|
+
window.location.reload();
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
ServerErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
777
|
+
ServerErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: ServerErrorComponent, selector: "lib-vc-error-server-error", ngImport: i0, template: `
|
|
778
|
+
<div class="errorPage">
|
|
779
|
+
<div class="errorPage-top">
|
|
780
|
+
<img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
|
|
781
|
+
</div>
|
|
782
|
+
<div class="errorPage-container">
|
|
783
|
+
<div class="errorPage-inner">
|
|
784
|
+
<div class="errorPage-inner-image">
|
|
785
|
+
<img
|
|
786
|
+
[src]="errorConfig.imageUrl"
|
|
787
|
+
alt="Error Image"
|
|
788
|
+
width="246"
|
|
789
|
+
height="178"
|
|
790
|
+
/>
|
|
791
|
+
</div>
|
|
792
|
+
<div class="errorPage-inner-right">
|
|
793
|
+
<div class="errorPage-heading">{{ errorConfig.title }}</div>
|
|
794
|
+
<div class="errorPage-text">{{ errorConfig.description }}</div>
|
|
795
|
+
<div class="errorPage-details">{{ errorConfig.details }}</div>
|
|
796
|
+
<button class="errorPage-btn" (click)="refreshPage()">
|
|
797
|
+
{{ errorConfig.buttonText }} <i class="icons"></i>
|
|
798
|
+
</button>
|
|
799
|
+
</div>
|
|
800
|
+
</div>
|
|
801
|
+
</div>
|
|
802
|
+
</div>
|
|
803
|
+
`, isInline: true, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] });
|
|
804
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, decorators: [{
|
|
805
|
+
type: Component,
|
|
806
|
+
args: [{ selector: 'lib-vc-error-server-error', template: `
|
|
807
|
+
<div class="errorPage">
|
|
808
|
+
<div class="errorPage-top">
|
|
809
|
+
<img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
|
|
810
|
+
</div>
|
|
811
|
+
<div class="errorPage-container">
|
|
812
|
+
<div class="errorPage-inner">
|
|
813
|
+
<div class="errorPage-inner-image">
|
|
814
|
+
<img
|
|
815
|
+
[src]="errorConfig.imageUrl"
|
|
816
|
+
alt="Error Image"
|
|
817
|
+
width="246"
|
|
818
|
+
height="178"
|
|
819
|
+
/>
|
|
820
|
+
</div>
|
|
821
|
+
<div class="errorPage-inner-right">
|
|
822
|
+
<div class="errorPage-heading">{{ errorConfig.title }}</div>
|
|
823
|
+
<div class="errorPage-text">{{ errorConfig.description }}</div>
|
|
824
|
+
<div class="errorPage-details">{{ errorConfig.details }}</div>
|
|
825
|
+
<button class="errorPage-btn" (click)="refreshPage()">
|
|
826
|
+
{{ errorConfig.buttonText }} <i class="icons"></i>
|
|
827
|
+
</button>
|
|
828
|
+
</div>
|
|
829
|
+
</div>
|
|
830
|
+
</div>
|
|
831
|
+
</div>
|
|
832
|
+
`, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] }]
|
|
833
|
+
}] });
|
|
834
|
+
|
|
600
835
|
class VcErrorHandlersComponent {
|
|
601
836
|
constructor(errorService, snackBarService) {
|
|
602
837
|
this.errorService = errorService;
|
|
@@ -605,6 +840,7 @@ class VcErrorHandlersComponent {
|
|
|
605
840
|
this.unauthorized = false;
|
|
606
841
|
this.sessionExpired = false;
|
|
607
842
|
this.chunkUnavailable = false;
|
|
843
|
+
this.serverError = false;
|
|
608
844
|
this.isOnline = navigator.onLine;
|
|
609
845
|
this.onNetworkOnline = () => {
|
|
610
846
|
this.isOnline = true;
|
|
@@ -641,6 +877,9 @@ class VcErrorHandlersComponent {
|
|
|
641
877
|
else if (error.status === ErrorStatusCode.NetworkUnavailable) {
|
|
642
878
|
this.handleNetworkError();
|
|
643
879
|
}
|
|
880
|
+
else if (this.errorService.isServerError(error)) {
|
|
881
|
+
this.serverError = true;
|
|
882
|
+
}
|
|
644
883
|
}
|
|
645
884
|
subscribeNetworkDetection() {
|
|
646
885
|
window.addEventListener('online', this.onNetworkOnline);
|
|
@@ -668,7 +907,8 @@ VcErrorHandlersComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0
|
|
|
668
907
|
<lib-vc-error-chunk-unavailable
|
|
669
908
|
*ngIf="chunkUnavailable"
|
|
670
909
|
></lib-vc-error-chunk-unavailable>
|
|
671
|
-
|
|
910
|
+
<lib-vc-error-server-error *ngIf="serverError"></lib-vc-error-server-error>
|
|
911
|
+
`, isInline: true, components: [{ type: SnackBarComponent, selector: "app-snack-bar" }, { type: SessionExpiredComponent, selector: "lib-vc-error-session-expired" }, { type: UnauthorizedComponent, selector: "lib-vc-error-unauthorized" }, { type: ChunkUnavailableComponent, selector: "lib-vc-error-chunk-unavailable" }, { type: ServerErrorComponent, selector: "lib-vc-error-server-error" }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
672
912
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersComponent, decorators: [{
|
|
673
913
|
type: Component,
|
|
674
914
|
args: [{
|
|
@@ -682,6 +922,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
682
922
|
<lib-vc-error-chunk-unavailable
|
|
683
923
|
*ngIf="chunkUnavailable"
|
|
684
924
|
></lib-vc-error-chunk-unavailable>
|
|
925
|
+
<lib-vc-error-server-error *ngIf="serverError"></lib-vc-error-server-error>
|
|
685
926
|
`,
|
|
686
927
|
}]
|
|
687
928
|
}], ctorParameters: function () { return [{ type: GlobalErrorService }, { type: SnackBarService }]; } });
|
|
@@ -765,74 +1006,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
765
1006
|
`, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] }]
|
|
766
1007
|
}], ctorParameters: function () { return [{ type: i3.Router }]; } });
|
|
767
1008
|
|
|
768
|
-
class ServerErrorComponent {
|
|
769
|
-
constructor() {
|
|
770
|
-
this.errorConfig = ERROR_CONFIG.SERVER_ERROR;
|
|
771
|
-
this.VcomplyLogo = VCOMPLY_LOGO_URL;
|
|
772
|
-
}
|
|
773
|
-
refreshPage() {
|
|
774
|
-
window.location.reload();
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
ServerErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
778
|
-
ServerErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: ServerErrorComponent, selector: "lib-vc-error-server-error", ngImport: i0, template: `
|
|
779
|
-
<div class="errorPage">
|
|
780
|
-
<div class="errorPage-top">
|
|
781
|
-
<img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
|
|
782
|
-
</div>
|
|
783
|
-
<div class="errorPage-container">
|
|
784
|
-
<div class="errorPage-inner">
|
|
785
|
-
<div class="errorPage-inner-image">
|
|
786
|
-
<img
|
|
787
|
-
[src]="errorConfig.imageUrl"
|
|
788
|
-
alt="Error Image"
|
|
789
|
-
width="246"
|
|
790
|
-
height="178"
|
|
791
|
-
/>
|
|
792
|
-
</div>
|
|
793
|
-
<div class="errorPage-inner-right">
|
|
794
|
-
<div class="errorPage-heading">{{ errorConfig.title }}</div>
|
|
795
|
-
<div class="errorPage-text">{{ errorConfig.description }}</div>
|
|
796
|
-
<div class="errorPage-details">{{ errorConfig.details }}</div>
|
|
797
|
-
<button class="errorPage-btn" (click)="refreshPage()">
|
|
798
|
-
{{ errorConfig.buttonText }} <i class="icons"></i>
|
|
799
|
-
</button>
|
|
800
|
-
</div>
|
|
801
|
-
</div>
|
|
802
|
-
</div>
|
|
803
|
-
</div>
|
|
804
|
-
`, isInline: true, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] });
|
|
805
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, decorators: [{
|
|
806
|
-
type: Component,
|
|
807
|
-
args: [{ selector: 'lib-vc-error-server-error', template: `
|
|
808
|
-
<div class="errorPage">
|
|
809
|
-
<div class="errorPage-top">
|
|
810
|
-
<img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
|
|
811
|
-
</div>
|
|
812
|
-
<div class="errorPage-container">
|
|
813
|
-
<div class="errorPage-inner">
|
|
814
|
-
<div class="errorPage-inner-image">
|
|
815
|
-
<img
|
|
816
|
-
[src]="errorConfig.imageUrl"
|
|
817
|
-
alt="Error Image"
|
|
818
|
-
width="246"
|
|
819
|
-
height="178"
|
|
820
|
-
/>
|
|
821
|
-
</div>
|
|
822
|
-
<div class="errorPage-inner-right">
|
|
823
|
-
<div class="errorPage-heading">{{ errorConfig.title }}</div>
|
|
824
|
-
<div class="errorPage-text">{{ errorConfig.description }}</div>
|
|
825
|
-
<div class="errorPage-details">{{ errorConfig.details }}</div>
|
|
826
|
-
<button class="errorPage-btn" (click)="refreshPage()">
|
|
827
|
-
{{ errorConfig.buttonText }} <i class="icons"></i>
|
|
828
|
-
</button>
|
|
829
|
-
</div>
|
|
830
|
-
</div>
|
|
831
|
-
</div>
|
|
832
|
-
</div>
|
|
833
|
-
`, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] }]
|
|
834
|
-
}] });
|
|
835
|
-
|
|
836
1009
|
class SnackBarModule {
|
|
837
1010
|
}
|
|
838
1011
|
SnackBarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SnackBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -897,37 +1070,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
897
1070
|
}] }]; } });
|
|
898
1071
|
|
|
899
1072
|
class HttpReqInterceptor {
|
|
900
|
-
constructor(errorService
|
|
1073
|
+
constructor(errorService) {
|
|
901
1074
|
this.errorService = errorService;
|
|
902
|
-
this.snackBarService = snackBarService;
|
|
903
1075
|
}
|
|
904
1076
|
intercept(req, next) {
|
|
905
1077
|
return next.handle(req).pipe(timeout(API_TIMEOUT_TIME), tap((event) => {
|
|
906
1078
|
if (event instanceof HttpResponse) {
|
|
907
|
-
this.handleSoftErrors(event);
|
|
1079
|
+
this.errorService.handleSoftErrors(event);
|
|
908
1080
|
}
|
|
909
1081
|
}), catchError((error) => {
|
|
910
1082
|
this.errorService.handleError(error, req);
|
|
911
1083
|
return throwError(error);
|
|
912
1084
|
}));
|
|
913
1085
|
}
|
|
914
|
-
handleSoftErrors(event) {
|
|
915
|
-
const xData = event.headers.get('X-Data');
|
|
916
|
-
if (xData) {
|
|
917
|
-
const parsedData = JSON.parse(xData);
|
|
918
|
-
const statusCode = parsedData.statusCode;
|
|
919
|
-
const statusMessage = parsedData.message;
|
|
920
|
-
if (statusCode && statusCode !== 0) {
|
|
921
|
-
this.snackBarService.show(statusMessage || 'Error occurred', 'error');
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
1086
|
}
|
|
926
|
-
HttpReqInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, deps: [{ token: GlobalErrorService }
|
|
1087
|
+
HttpReqInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, deps: [{ token: GlobalErrorService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
927
1088
|
HttpReqInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor });
|
|
928
1089
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, decorators: [{
|
|
929
1090
|
type: Injectable
|
|
930
|
-
}], ctorParameters: function () { return [{ type: GlobalErrorService }
|
|
1091
|
+
}], ctorParameters: function () { return [{ type: GlobalErrorService }]; } });
|
|
931
1092
|
|
|
932
1093
|
const FOR_ROOT_SENTRY_OPTIONS_TOKEN = new InjectionToken('forRoot() SentryErrorHandler options');
|
|
933
1094
|
class VcErrorHandlersModule {
|