@rxap/ngx-error 16.0.1-dev.0
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/CHANGELOG.md +8 -0
- package/LICENSE +621 -0
- package/LICENSE.md +621 -0
- package/README.md +20 -0
- package/esm2022/index.mjs +27 -0
- package/esm2022/lib/any-http-error/any-http-error-dialog-data.mjs +2 -0
- package/esm2022/lib/any-http-error/any-http-error.component.mjs +30 -0
- package/esm2022/lib/any-http-error/any-http-error.service.mjs +20 -0
- package/esm2022/lib/code-http-error/code-http-error-dialog-data.mjs +2 -0
- package/esm2022/lib/code-http-error/code-http-error.component.mjs +23 -0
- package/esm2022/lib/code-http-error/code-http-error.service.mjs +20 -0
- package/esm2022/lib/error-capture.service.mjs +59 -0
- package/esm2022/lib/error-dialog/error-dialog.component.mjs +58 -0
- package/esm2022/lib/error-handler.mjs +81 -0
- package/esm2022/lib/error-interceptor-options.mjs +7 -0
- package/esm2022/lib/http-error-interceptor.mjs +71 -0
- package/esm2022/lib/message-http-error/message-http-error-dialog-data.mjs +2 -0
- package/esm2022/lib/message-http-error/message-http-error.component.mjs +23 -0
- package/esm2022/lib/message-http-error/message-http-error.service.mjs +20 -0
- package/esm2022/lib/tokens.mjs +6 -0
- package/esm2022/lib/utilities.mjs +79 -0
- package/esm2022/rxap-ngx-error.mjs +5 -0
- package/fesm2022/rxap-ngx-error.mjs +459 -0
- package/fesm2022/rxap-ngx-error.mjs.map +1 -0
- package/index.d.ts +16 -0
- package/lib/any-http-error/any-http-error-dialog-data.d.ts +12 -0
- package/lib/any-http-error/any-http-error.component.d.ts +9 -0
- package/lib/any-http-error/any-http-error.service.d.ts +10 -0
- package/lib/code-http-error/code-http-error-dialog-data.d.ts +7 -0
- package/lib/code-http-error/code-http-error.component.d.ts +10 -0
- package/lib/code-http-error/code-http-error.service.d.ts +10 -0
- package/lib/error-capture.service.d.ts +14 -0
- package/lib/error-dialog/error-dialog.component.d.ts +20 -0
- package/lib/error-handler.d.ts +19 -0
- package/lib/error-interceptor-options.d.ts +7 -0
- package/lib/http-error-interceptor.d.ts +3 -0
- package/lib/message-http-error/message-http-error-dialog-data.d.ts +6 -0
- package/lib/message-http-error/message-http-error.component.d.ts +10 -0
- package/lib/message-http-error/message-http-error.service.d.ts +10 -0
- package/lib/tokens.d.ts +8 -0
- package/lib/utilities.d.ts +17 -0
- package/package.json +60 -0
- package/theme.css +1 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
|
2
|
+
export function SimplifyHttpErrorResponse(event) {
|
|
3
|
+
let error = event.error;
|
|
4
|
+
if (typeof error !== 'object') {
|
|
5
|
+
if (error instanceof Blob) {
|
|
6
|
+
console.warn('error response object is a blob');
|
|
7
|
+
error = '[BLOB]';
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
try {
|
|
11
|
+
error = JSON.parse(error);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
console.warn('error response object is not a json');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
errorMessage: (typeof error === 'object' ? error?.message : undefined) ?? event.message,
|
|
20
|
+
error: error,
|
|
21
|
+
message: event.message,
|
|
22
|
+
name: event.name,
|
|
23
|
+
status: event.status,
|
|
24
|
+
statusText: event.statusText,
|
|
25
|
+
url: event.url,
|
|
26
|
+
headers: event.headers.keys()
|
|
27
|
+
.reduce((map, key) => ({
|
|
28
|
+
...map,
|
|
29
|
+
[key]: event.headers.getAll(key),
|
|
30
|
+
}), {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function ExtractContextFromError(error) {
|
|
34
|
+
const context = {};
|
|
35
|
+
if (error instanceof HttpErrorResponse) {
|
|
36
|
+
context['response'] = SimplifyHttpErrorResponse(error);
|
|
37
|
+
}
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
export function ExtractExtraFromError(error) {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
export function ExtractTagsFromError(error) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
export function ExtractError(error) {
|
|
47
|
+
if (error instanceof HttpErrorResponse) {
|
|
48
|
+
return error;
|
|
49
|
+
}
|
|
50
|
+
if (error instanceof Error) {
|
|
51
|
+
return error;
|
|
52
|
+
}
|
|
53
|
+
if (typeof error === 'string') {
|
|
54
|
+
return error;
|
|
55
|
+
}
|
|
56
|
+
return 'Handled unknown error';
|
|
57
|
+
}
|
|
58
|
+
export function PrintError(errorCandidate) {
|
|
59
|
+
if (errorCandidate instanceof HttpErrorResponse) {
|
|
60
|
+
console.groupCollapsed(errorCandidate.message);
|
|
61
|
+
const { headers, error, ...map } = SimplifyHttpErrorResponse(errorCandidate);
|
|
62
|
+
if (typeof error === 'object' && error?.message) {
|
|
63
|
+
console.log(error?.message);
|
|
64
|
+
}
|
|
65
|
+
console.log(error);
|
|
66
|
+
console.table(map);
|
|
67
|
+
console.groupCollapsed('Headers');
|
|
68
|
+
console.table(headers);
|
|
69
|
+
console.groupEnd();
|
|
70
|
+
console.groupEnd();
|
|
71
|
+
}
|
|
72
|
+
else if (errorCandidate instanceof Error) {
|
|
73
|
+
console.error(errorCandidate);
|
|
74
|
+
}
|
|
75
|
+
else if (typeof errorCandidate === 'string') {
|
|
76
|
+
console.error(errorCandidate);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbGl0aWVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvYW5ndWxhci9lcnJvci9zcmMvbGliL3V0aWxpdGllcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxzQkFBc0IsQ0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biAgfVxufVxuIl19
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './index';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnhhcC1uZ3gtZXJyb3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9hbmd1bGFyL2Vycm9yL3NyYy9yeGFwLW5neC1lcnJvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { NgIf, DatePipe, KeyValuePipe, NgForOf, JsonPipe, NgClass } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { InjectionToken, inject, Component, ChangeDetectionStrategy, signal, computed, EventEmitter, INJECTOR, Injector, ViewChild, Output, ApplicationRef, createComponent, Injectable, isDevMode, ErrorHandler } from '@angular/core';
|
|
4
|
+
import { RXAP_ENVIRONMENT } from '@rxap/environment';
|
|
5
|
+
import { CopyToClipboardComponent, JsonViewerComponent } from '@rxap/components';
|
|
6
|
+
import * as i1 from '@rxap/data-grid';
|
|
7
|
+
import { DataGridModule } from '@rxap/data-grid';
|
|
8
|
+
import { take } from 'rxjs';
|
|
9
|
+
import { tap } from 'rxjs/operators';
|
|
10
|
+
import * as i1$1 from '@angular/cdk/portal';
|
|
11
|
+
import { ComponentPortal, PortalModule } from '@angular/cdk/portal';
|
|
12
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
|
13
|
+
import { ConfigService } from '@rxap/config';
|
|
14
|
+
import * as Sentry from '@sentry/angular-ivy';
|
|
15
|
+
|
|
16
|
+
const RXAP_ERROR_DIALOG_DATA = new InjectionToken('rxap/http-error-message/dialog-data');
|
|
17
|
+
const RXAP_ERROR_DIALOG_ERROR = new InjectionToken('rxap/http-error-message/dialog-data');
|
|
18
|
+
const RXAP_ERROR_DIALOG_COMPONENT = new InjectionToken('rxap/http-error-message/dialog-component');
|
|
19
|
+
const RXAP_ERROR_INTERCEPTOR_OPTIONS = new InjectionToken('rxap/http-error-message/interceptor-options');
|
|
20
|
+
|
|
21
|
+
class AnyHttpErrorComponent {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.isProduction = inject(RXAP_ENVIRONMENT, { optional: true })?.production ?? false;
|
|
24
|
+
this.error = inject(RXAP_ERROR_DIALOG_ERROR);
|
|
25
|
+
}
|
|
26
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AnyHttpErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
27
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: AnyHttpErrorComponent, isStandalone: true, selector: "rxap-any-http-error", ngImport: i0, template: "<rxap-data-grid [data]=\"error\">\n <ng-container rxapDataGridRowDef=\"name\"></ng-container>\n <ng-container rxapDataGridRowDef=\"timestamp\">\n <td *rxapDataGridCellDef=\"let value\">{{ value | date:'HH:mm:ss' }}</td>\n </ng-container>\n <ng-container rxapDataGridRowDef=\"method\"></ng-container>\n <ng-container rxapDataGridRowDef=\"url\"></ng-container>\n <ng-container rxapDataGridRowDef=\"status\"></ng-container>\n <ng-container rxapDataGridRowDef=\"statusText\"></ng-container>\n <ng-container rxapDataGridRowDef=\"message\"></ng-container>\n <ng-container rxapDataGridRowDef=\"headers\">\n <td *rxapDataGridCellDef=\"let value\">\n <rxap-data-grid [data]=\"value\">\n <ng-container *ngFor=\"let entry of value | keyvalue\" [rxapDataGridRowDef]=\"$any(entry.key)\">\n <td *rxapDataGridCellDef=\"let value\">\n <ng-container *ngIf=\"value.length > 1\">\n <ul>\n <li *ngFor=\"let item of value\">{{ item }}</li>\n </ul>\n </ng-container>\n <ng-container *ngIf=\"value.length === 1\">{{ value[0] }}</ng-container>\n <ng-container *ngIf=\"value.length === 0\">NONE</ng-container>\n </td>\n </ng-container>\n </rxap-data-grid>\n </td>\n </ng-container>\n <ng-container *ngIf=\"!isProduction\" rxapDataGridRowDef=\"error\">\n <td *rxapDataGridCellDef=\"let value\">\n <ng-container *ngIf=\"value\">\n <rxap-copy-to-clipboard [value]=\"value | json\">Copy Response Body</rxap-copy-to-clipboard>\n <div class=\"body\">\n <rxap-json-viewer [expanded]=\"false\" [json]=\"value\"></rxap-json-viewer>\n </div>\n </ng-container>\n <ng-container *ngIf=\"!value\">NONE</ng-container>\n </td>\n </ng-container>\n <ng-container *ngIf=\"!isProduction\" rxapDataGridRowDef=\"body\">\n <td *rxapDataGridCellDef=\"let value\">\n <ng-container *ngIf=\"value\">\n <rxap-copy-to-clipboard [value]=\"value | json\">Copy Request Body</rxap-copy-to-clipboard>\n <div class=\"body\">\n <rxap-json-viewer [expanded]=\"false\" [json]=\"value\"></rxap-json-viewer>\n </div>\n </ng-container>\n <ng-container *ngIf=\"!value\">NONE</ng-container>\n </td>\n </ng-container>\n</rxap-data-grid>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: DataGridModule }, { kind: "component", type: i1.DataGridComponent, selector: "rxap-data-grid", inputs: ["header", "dataSource", "viewer", "data", "displayProperties", "mode"], outputs: ["editModeChange"] }, { kind: "directive", type: i1.DataGridRowDefDirective, selector: "[rxapDataGridRowDef]", inputs: ["data", "rxapDataGridRowDef", "flip"] }, { kind: "directive", type: i1.DataGridCellDefDirective, selector: "[rxapDataGridCellDef]" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: DatePipe, name: "date" }, { kind: "pipe", type: KeyValuePipe, name: "keyvalue" }, { kind: "directive", type: NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: CopyToClipboardComponent, selector: "rxap-copy-to-clipboard", inputs: ["active", "disabled", "value"] }, { kind: "pipe", type: JsonPipe, name: "json" }, { kind: "component", type: JsonViewerComponent, selector: "rxap-json-viewer", inputs: ["json", "expanded"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
28
|
+
}
|
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AnyHttpErrorComponent, decorators: [{
|
|
30
|
+
type: Component,
|
|
31
|
+
args: [{ selector: 'rxap-any-http-error', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
|
|
32
|
+
DataGridModule,
|
|
33
|
+
NgIf,
|
|
34
|
+
DatePipe,
|
|
35
|
+
KeyValuePipe,
|
|
36
|
+
NgForOf,
|
|
37
|
+
CopyToClipboardComponent,
|
|
38
|
+
JsonPipe,
|
|
39
|
+
JsonViewerComponent,
|
|
40
|
+
], template: "<rxap-data-grid [data]=\"error\">\n <ng-container rxapDataGridRowDef=\"name\"></ng-container>\n <ng-container rxapDataGridRowDef=\"timestamp\">\n <td *rxapDataGridCellDef=\"let value\">{{ value | date:'HH:mm:ss' }}</td>\n </ng-container>\n <ng-container rxapDataGridRowDef=\"method\"></ng-container>\n <ng-container rxapDataGridRowDef=\"url\"></ng-container>\n <ng-container rxapDataGridRowDef=\"status\"></ng-container>\n <ng-container rxapDataGridRowDef=\"statusText\"></ng-container>\n <ng-container rxapDataGridRowDef=\"message\"></ng-container>\n <ng-container rxapDataGridRowDef=\"headers\">\n <td *rxapDataGridCellDef=\"let value\">\n <rxap-data-grid [data]=\"value\">\n <ng-container *ngFor=\"let entry of value | keyvalue\" [rxapDataGridRowDef]=\"$any(entry.key)\">\n <td *rxapDataGridCellDef=\"let value\">\n <ng-container *ngIf=\"value.length > 1\">\n <ul>\n <li *ngFor=\"let item of value\">{{ item }}</li>\n </ul>\n </ng-container>\n <ng-container *ngIf=\"value.length === 1\">{{ value[0] }}</ng-container>\n <ng-container *ngIf=\"value.length === 0\">NONE</ng-container>\n </td>\n </ng-container>\n </rxap-data-grid>\n </td>\n </ng-container>\n <ng-container *ngIf=\"!isProduction\" rxapDataGridRowDef=\"error\">\n <td *rxapDataGridCellDef=\"let value\">\n <ng-container *ngIf=\"value\">\n <rxap-copy-to-clipboard [value]=\"value | json\">Copy Response Body</rxap-copy-to-clipboard>\n <div class=\"body\">\n <rxap-json-viewer [expanded]=\"false\" [json]=\"value\"></rxap-json-viewer>\n </div>\n </ng-container>\n <ng-container *ngIf=\"!value\">NONE</ng-container>\n </td>\n </ng-container>\n <ng-container *ngIf=\"!isProduction\" rxapDataGridRowDef=\"body\">\n <td *rxapDataGridCellDef=\"let value\">\n <ng-container *ngIf=\"value\">\n <rxap-copy-to-clipboard [value]=\"value | json\">Copy Request Body</rxap-copy-to-clipboard>\n <div class=\"body\">\n <rxap-json-viewer [expanded]=\"false\" [json]=\"value\"></rxap-json-viewer>\n </div>\n </ng-container>\n <ng-container *ngIf=\"!value\">NONE</ng-container>\n </td>\n </ng-container>\n</rxap-data-grid>\n" }]
|
|
41
|
+
}] });
|
|
42
|
+
|
|
43
|
+
class MessageHttpErrorComponent {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.isProduction = inject(RXAP_ENVIRONMENT, { optional: true })?.production ?? false;
|
|
46
|
+
this.error = inject(RXAP_ERROR_DIALOG_ERROR);
|
|
47
|
+
this.showMore = signal(false);
|
|
48
|
+
}
|
|
49
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MessageHttpErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
50
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: MessageHttpErrorComponent, isStandalone: true, selector: "rxap-http-error-message", ngImport: i0, template: "<div class=\"flex flex-col gap-2\">\n <p class=\"text-xl\">Http Error Message:</p>\n <p>{{ error.error.message }}</p>\n <ng-container *ngIf=\"!isProduction\">\n <hr>\n <button (click)=\"showMore.set(true)\"\n *ngIf=\"!showMore()\"\n class=\"px-4 py-2 rounded bg-accent-500\">\n <ng-container i18n>Show more details</ng-container>\n </button>\n <rxap-any-http-error *ngIf=\"showMore()\"></rxap-any-http-error>\n </ng-container>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: AnyHttpErrorComponent, selector: "rxap-any-http-error" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
51
|
+
}
|
|
52
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MessageHttpErrorComponent, decorators: [{
|
|
53
|
+
type: Component,
|
|
54
|
+
args: [{ selector: 'rxap-http-error-message', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
|
|
55
|
+
NgIf,
|
|
56
|
+
AnyHttpErrorComponent,
|
|
57
|
+
], template: "<div class=\"flex flex-col gap-2\">\n <p class=\"text-xl\">Http Error Message:</p>\n <p>{{ error.error.message }}</p>\n <ng-container *ngIf=\"!isProduction\">\n <hr>\n <button (click)=\"showMore.set(true)\"\n *ngIf=\"!showMore()\"\n class=\"px-4 py-2 rounded bg-accent-500\">\n <ng-container i18n>Show more details</ng-container>\n </button>\n <rxap-any-http-error *ngIf=\"showMore()\"></rxap-any-http-error>\n </ng-container>\n</div>\n" }]
|
|
58
|
+
}] });
|
|
59
|
+
|
|
60
|
+
class ErrorDialogComponent {
|
|
61
|
+
constructor() {
|
|
62
|
+
this.data = inject(RXAP_ERROR_DIALOG_DATA);
|
|
63
|
+
this.activeIndex = signal(0);
|
|
64
|
+
this.displayedButtons = computed(() => {
|
|
65
|
+
const start = Math.max(0, this.activeIndex() - 2);
|
|
66
|
+
const end = Math.min(this.data().length, start + 5);
|
|
67
|
+
return Array.from({ length: end - start }, (_, i) => start + i);
|
|
68
|
+
});
|
|
69
|
+
this.closeDialog = new EventEmitter();
|
|
70
|
+
this.component = inject(RXAP_ERROR_DIALOG_COMPONENT);
|
|
71
|
+
this.injector = inject(INJECTOR);
|
|
72
|
+
this.componentPortal = computed(() => {
|
|
73
|
+
const index = this.activeIndex();
|
|
74
|
+
const data = this.data();
|
|
75
|
+
const injector = Injector.create({
|
|
76
|
+
parent: this.injector,
|
|
77
|
+
providers: [
|
|
78
|
+
{
|
|
79
|
+
provide: RXAP_ERROR_DIALOG_ERROR,
|
|
80
|
+
useValue: data[index],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
return new ComponentPortal(this.component, null, injector);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
ngAfterViewInit() {
|
|
88
|
+
this.dialog.nativeElement.showModal();
|
|
89
|
+
}
|
|
90
|
+
close() {
|
|
91
|
+
this.dialog.nativeElement.close();
|
|
92
|
+
this.closeDialog.emit();
|
|
93
|
+
}
|
|
94
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ErrorDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
95
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: ErrorDialogComponent, isStandalone: true, selector: "rxap-error-dialog", outputs: { closeDialog: "closeDialog" }, viewQueries: [{ propertyName: "dialog", first: true, predicate: ["dialog"], descendants: true, static: true }], ngImport: i0, template: "<dialog #dialog\n class=\"max-w-6xl rounded overflow-auto drop-shadow-2xl dark:bg-black dark:text-white flex flex-col gap-3\">\n <div *ngIf=\"data().length > 1\" class=\"controls flex justify-center space-x-2 mt-4\">\n <button\n (click)=\"activeIndex.set(activeIndex() - 1)\"\n *ngIf=\"activeIndex() > 0\" class=\"px-4 py-2 bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-900 hover:bg-gray-300 transition-colors duration-150 rounded\">Previous\n </button>\n <button (click)=\"activeIndex.set(item)\"\n *ngFor=\"let item of displayedButtons()\"\n [ngClass]=\"{\n 'bg-primary-500': item === activeIndex(),\n 'bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-900 hover:bg-gray-300 transition-colors duration-150': item !== activeIndex()\n }\"\n class=\"px-4 py-2 rounded\">\n {{ item + 1 }}\n </button>\n <button\n (click)=\"activeIndex.set(activeIndex() + 1)\"\n *ngIf=\"activeIndex() < data().length - 1\" class=\"px-4 py-2 bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-900 hover:bg-gray-300 transition-colors duration-150 rounded\">Next\n </button>\n </div>\n <ng-template [cdkPortalOutlet]=\"componentPortal()\"></ng-template>\n <button (click)=\"close()\" class=\"px-4 py-2 rounded bg-primary-500\" i18n>close</button>\n</dialog>\n", styles: ["dialog::-webkit-backdrop{background:rgba(0,0,0,.7)}dialog::backdrop{background:rgba(0,0,0,.7)}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "ngmodule", type: PortalModule }, { kind: "directive", type: i1$1.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.Default }); }
|
|
96
|
+
}
|
|
97
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ErrorDialogComponent, decorators: [{
|
|
98
|
+
type: Component,
|
|
99
|
+
args: [{ selector: 'rxap-error-dialog', changeDetection: ChangeDetectionStrategy.Default, standalone: true, imports: [
|
|
100
|
+
NgIf,
|
|
101
|
+
NgClass,
|
|
102
|
+
NgForOf,
|
|
103
|
+
PortalModule,
|
|
104
|
+
], template: "<dialog #dialog\n class=\"max-w-6xl rounded overflow-auto drop-shadow-2xl dark:bg-black dark:text-white flex flex-col gap-3\">\n <div *ngIf=\"data().length > 1\" class=\"controls flex justify-center space-x-2 mt-4\">\n <button\n (click)=\"activeIndex.set(activeIndex() - 1)\"\n *ngIf=\"activeIndex() > 0\" class=\"px-4 py-2 bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-900 hover:bg-gray-300 transition-colors duration-150 rounded\">Previous\n </button>\n <button (click)=\"activeIndex.set(item)\"\n *ngFor=\"let item of displayedButtons()\"\n [ngClass]=\"{\n 'bg-primary-500': item === activeIndex(),\n 'bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-900 hover:bg-gray-300 transition-colors duration-150': item !== activeIndex()\n }\"\n class=\"px-4 py-2 rounded\">\n {{ item + 1 }}\n </button>\n <button\n (click)=\"activeIndex.set(activeIndex() + 1)\"\n *ngIf=\"activeIndex() < data().length - 1\" class=\"px-4 py-2 bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-900 hover:bg-gray-300 transition-colors duration-150 rounded\">Next\n </button>\n </div>\n <ng-template [cdkPortalOutlet]=\"componentPortal()\"></ng-template>\n <button (click)=\"close()\" class=\"px-4 py-2 rounded bg-primary-500\" i18n>close</button>\n</dialog>\n", styles: ["dialog::-webkit-backdrop{background:rgba(0,0,0,.7)}dialog::backdrop{background:rgba(0,0,0,.7)}\n"] }]
|
|
105
|
+
}], propDecorators: { dialog: [{
|
|
106
|
+
type: ViewChild,
|
|
107
|
+
args: ['dialog', { static: true }]
|
|
108
|
+
}], closeDialog: [{
|
|
109
|
+
type: Output
|
|
110
|
+
}] } });
|
|
111
|
+
|
|
112
|
+
class ErrorCaptureService {
|
|
113
|
+
constructor() {
|
|
114
|
+
this.applicationRef = inject(ApplicationRef);
|
|
115
|
+
this.errorList = [];
|
|
116
|
+
}
|
|
117
|
+
push(error) {
|
|
118
|
+
if (this.errorList.length) {
|
|
119
|
+
const last = this.errorList[this.errorList.length - 1];
|
|
120
|
+
const value = last();
|
|
121
|
+
if (value.some(e => this.compare(e, error))) {
|
|
122
|
+
last.mutate(value => value.push(error));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const newList = signal([error]);
|
|
127
|
+
this.errorList.push(newList);
|
|
128
|
+
this.openDialog(newList);
|
|
129
|
+
}
|
|
130
|
+
openDialog(errorList) {
|
|
131
|
+
const body = document.getElementsByTagName('body')[0];
|
|
132
|
+
const div = document.createElement('div');
|
|
133
|
+
body.appendChild(div);
|
|
134
|
+
const componentRef = createComponent(ErrorDialogComponent, {
|
|
135
|
+
hostElement: div,
|
|
136
|
+
environmentInjector: this.applicationRef.injector,
|
|
137
|
+
elementInjector: Injector.create({
|
|
138
|
+
providers: [
|
|
139
|
+
{
|
|
140
|
+
provide: RXAP_ERROR_DIALOG_DATA,
|
|
141
|
+
useValue: errorList,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
provide: RXAP_ERROR_DIALOG_COMPONENT,
|
|
145
|
+
useValue: this.component,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
}),
|
|
149
|
+
});
|
|
150
|
+
this.applicationRef.attachView(componentRef.hostView);
|
|
151
|
+
componentRef.instance.closeDialog.pipe(take(1), tap(() => {
|
|
152
|
+
componentRef.destroy();
|
|
153
|
+
body.removeChild(div);
|
|
154
|
+
div.remove();
|
|
155
|
+
this.errorList.splice(this.errorList.indexOf(errorList), 1);
|
|
156
|
+
})).subscribe();
|
|
157
|
+
}
|
|
158
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ErrorCaptureService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
159
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ErrorCaptureService }); }
|
|
160
|
+
}
|
|
161
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ErrorCaptureService, decorators: [{
|
|
162
|
+
type: Injectable
|
|
163
|
+
}] });
|
|
164
|
+
|
|
165
|
+
class AnyHttpErrorService extends ErrorCaptureService {
|
|
166
|
+
constructor() {
|
|
167
|
+
super(...arguments);
|
|
168
|
+
this.component = AnyHttpErrorComponent;
|
|
169
|
+
}
|
|
170
|
+
compare(a, b) {
|
|
171
|
+
return a.url === b.url && a.method === b.method && a.status === b.status && a.message === b.message;
|
|
172
|
+
}
|
|
173
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AnyHttpErrorService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
174
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AnyHttpErrorService, providedIn: 'root' }); }
|
|
175
|
+
}
|
|
176
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AnyHttpErrorService, decorators: [{
|
|
177
|
+
type: Injectable,
|
|
178
|
+
args: [{ providedIn: 'root' }]
|
|
179
|
+
}] });
|
|
180
|
+
|
|
181
|
+
class MessageHttpErrorService extends AnyHttpErrorService {
|
|
182
|
+
constructor() {
|
|
183
|
+
super(...arguments);
|
|
184
|
+
this.component = MessageHttpErrorComponent;
|
|
185
|
+
}
|
|
186
|
+
compare(a, b) {
|
|
187
|
+
return super.compare(a, b) && a.error.message === b.error.message;
|
|
188
|
+
}
|
|
189
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MessageHttpErrorService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
190
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MessageHttpErrorService, providedIn: 'root' }); }
|
|
191
|
+
}
|
|
192
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MessageHttpErrorService, decorators: [{
|
|
193
|
+
type: Injectable,
|
|
194
|
+
args: [{ providedIn: 'root' }]
|
|
195
|
+
}] });
|
|
196
|
+
|
|
197
|
+
class CodeHttpErrorComponent {
|
|
198
|
+
constructor() {
|
|
199
|
+
this.isProduction = inject(RXAP_ENVIRONMENT, { optional: true })?.production ?? false;
|
|
200
|
+
this.error = inject(RXAP_ERROR_DIALOG_ERROR);
|
|
201
|
+
this.showMore = signal(false);
|
|
202
|
+
}
|
|
203
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: CodeHttpErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
204
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: CodeHttpErrorComponent, isStandalone: true, selector: "rxap-http-error-message", ngImport: i0, template: "<div class=\"flex flex-col gap-2\">\n <p class=\"text-xl\">Http Error Code: <span class=\"font-bold text-red-800\">{{ error.errorCode }}</span></p>\n <p>{{ error.error.message ?? error.message }}</p>\n <ng-container *ngIf=\"!isProduction\">\n <hr>\n <button (click)=\"showMore.set(true)\"\n *ngIf=\"!showMore()\"\n class=\"px-4 py-2 rounded bg-accent-500\">\n <ng-container i18n>Show more details</ng-container>\n </button>\n <rxap-any-http-error *ngIf=\"showMore()\"></rxap-any-http-error>\n </ng-container>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: AnyHttpErrorComponent, selector: "rxap-any-http-error" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
205
|
+
}
|
|
206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: CodeHttpErrorComponent, decorators: [{
|
|
207
|
+
type: Component,
|
|
208
|
+
args: [{ selector: 'rxap-http-error-message', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
|
|
209
|
+
NgIf,
|
|
210
|
+
AnyHttpErrorComponent,
|
|
211
|
+
], template: "<div class=\"flex flex-col gap-2\">\n <p class=\"text-xl\">Http Error Code: <span class=\"font-bold text-red-800\">{{ error.errorCode }}</span></p>\n <p>{{ error.error.message ?? error.message }}</p>\n <ng-container *ngIf=\"!isProduction\">\n <hr>\n <button (click)=\"showMore.set(true)\"\n *ngIf=\"!showMore()\"\n class=\"px-4 py-2 rounded bg-accent-500\">\n <ng-container i18n>Show more details</ng-container>\n </button>\n <rxap-any-http-error *ngIf=\"showMore()\"></rxap-any-http-error>\n </ng-container>\n</div>\n" }]
|
|
212
|
+
}] });
|
|
213
|
+
|
|
214
|
+
class CodeHttpErrorService extends AnyHttpErrorService {
|
|
215
|
+
constructor() {
|
|
216
|
+
super(...arguments);
|
|
217
|
+
this.component = CodeHttpErrorComponent;
|
|
218
|
+
}
|
|
219
|
+
compare(a, b) {
|
|
220
|
+
return super.compare(a, b) && a.errorCode === b.errorCode;
|
|
221
|
+
}
|
|
222
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: CodeHttpErrorService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
223
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: CodeHttpErrorService, providedIn: 'root' }); }
|
|
224
|
+
}
|
|
225
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: CodeHttpErrorService, decorators: [{
|
|
226
|
+
type: Injectable,
|
|
227
|
+
args: [{ providedIn: 'root' }]
|
|
228
|
+
}] });
|
|
229
|
+
|
|
230
|
+
function SimplifyHttpErrorResponse(event) {
|
|
231
|
+
let error = event.error;
|
|
232
|
+
if (typeof error !== 'object') {
|
|
233
|
+
if (error instanceof Blob) {
|
|
234
|
+
console.warn('error response object is a blob');
|
|
235
|
+
error = '[BLOB]';
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
try {
|
|
239
|
+
error = JSON.parse(error);
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
console.warn('error response object is not a json');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
errorMessage: (typeof error === 'object' ? error?.message : undefined) ?? event.message,
|
|
248
|
+
error: error,
|
|
249
|
+
message: event.message,
|
|
250
|
+
name: event.name,
|
|
251
|
+
status: event.status,
|
|
252
|
+
statusText: event.statusText,
|
|
253
|
+
url: event.url,
|
|
254
|
+
headers: event.headers.keys()
|
|
255
|
+
.reduce((map, key) => ({
|
|
256
|
+
...map,
|
|
257
|
+
[key]: event.headers.getAll(key),
|
|
258
|
+
}), {}),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function ExtractContextFromError(error) {
|
|
262
|
+
const context = {};
|
|
263
|
+
if (error instanceof HttpErrorResponse) {
|
|
264
|
+
context['response'] = SimplifyHttpErrorResponse(error);
|
|
265
|
+
}
|
|
266
|
+
return context;
|
|
267
|
+
}
|
|
268
|
+
function ExtractExtraFromError(error) {
|
|
269
|
+
return {};
|
|
270
|
+
}
|
|
271
|
+
function ExtractTagsFromError(error) {
|
|
272
|
+
return {};
|
|
273
|
+
}
|
|
274
|
+
function ExtractError(error) {
|
|
275
|
+
if (error instanceof HttpErrorResponse) {
|
|
276
|
+
return error;
|
|
277
|
+
}
|
|
278
|
+
if (error instanceof Error) {
|
|
279
|
+
return error;
|
|
280
|
+
}
|
|
281
|
+
if (typeof error === 'string') {
|
|
282
|
+
return error;
|
|
283
|
+
}
|
|
284
|
+
return 'Handled unknown error';
|
|
285
|
+
}
|
|
286
|
+
function PrintError(errorCandidate) {
|
|
287
|
+
if (errorCandidate instanceof HttpErrorResponse) {
|
|
288
|
+
console.groupCollapsed(errorCandidate.message);
|
|
289
|
+
const { headers, error, ...map } = SimplifyHttpErrorResponse(errorCandidate);
|
|
290
|
+
if (typeof error === 'object' && error?.message) {
|
|
291
|
+
console.log(error?.message);
|
|
292
|
+
}
|
|
293
|
+
console.log(error);
|
|
294
|
+
console.table(map);
|
|
295
|
+
console.groupCollapsed('Headers');
|
|
296
|
+
console.table(headers);
|
|
297
|
+
console.groupEnd();
|
|
298
|
+
console.groupEnd();
|
|
299
|
+
}
|
|
300
|
+
else if (errorCandidate instanceof Error) {
|
|
301
|
+
console.error(errorCandidate);
|
|
302
|
+
}
|
|
303
|
+
else if (typeof errorCandidate === 'string') {
|
|
304
|
+
console.error(errorCandidate);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const RXAP_ERROR_HANDLER_OPTIONS = new InjectionToken('rxap-error-handler-options', {
|
|
309
|
+
providedIn: 'root',
|
|
310
|
+
factory: () => ({ logErrors: true }),
|
|
311
|
+
});
|
|
312
|
+
class RxapErrorHandler {
|
|
313
|
+
constructor() {
|
|
314
|
+
this.options = (() => {
|
|
315
|
+
const options = inject(RXAP_ERROR_HANDLER_OPTIONS);
|
|
316
|
+
const config = inject(ConfigService);
|
|
317
|
+
options.logErrors ??= true;
|
|
318
|
+
options.showDialog ??= config.get('sentry.showDialog', false);
|
|
319
|
+
// enforce showDialog to false in dev mode
|
|
320
|
+
options.showDialog = !isDevMode() && options.showDialog;
|
|
321
|
+
options.dialogOptions ??= config.get('sentry.dialogOptions', {});
|
|
322
|
+
options.dialogOptions.user ??= {};
|
|
323
|
+
return options;
|
|
324
|
+
})();
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Method called for every value captured through the ErrorHandler
|
|
328
|
+
*/
|
|
329
|
+
handleError(errorCandidate) {
|
|
330
|
+
let error = errorCandidate;
|
|
331
|
+
// Try to unwrap zone.js error.
|
|
332
|
+
// https://github.com/angular/angular/blob/master/packages/core/src/util/errors.ts
|
|
333
|
+
if (error && error.ngOriginalError) {
|
|
334
|
+
error = error.ngOriginalError;
|
|
335
|
+
}
|
|
336
|
+
const extractedError = ExtractError(error);
|
|
337
|
+
const contexts = ExtractContextFromError(error);
|
|
338
|
+
const extra = ExtractExtraFromError(error);
|
|
339
|
+
const tags = ExtractTagsFromError(error);
|
|
340
|
+
let eventId;
|
|
341
|
+
// Capture handled exception and send it to Sentry.
|
|
342
|
+
if (typeof extractedError === 'string') {
|
|
343
|
+
eventId = Sentry.captureMessage(extractedError, {
|
|
344
|
+
level: 'error',
|
|
345
|
+
contexts,
|
|
346
|
+
extra,
|
|
347
|
+
tags,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
eventId = Sentry.captureException(extractedError, {
|
|
352
|
+
level: 'error',
|
|
353
|
+
contexts,
|
|
354
|
+
extra,
|
|
355
|
+
tags,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
if (this.options.logErrors) {
|
|
359
|
+
PrintError(error);
|
|
360
|
+
}
|
|
361
|
+
if (this.options.showDialog) {
|
|
362
|
+
if (!(error instanceof HttpErrorResponse)) {
|
|
363
|
+
Sentry.showReportDialog({
|
|
364
|
+
...(this.options.dialogOptions ?? {}),
|
|
365
|
+
eventId,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: RxapErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
371
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: RxapErrorHandler }); }
|
|
372
|
+
}
|
|
373
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: RxapErrorHandler, decorators: [{
|
|
374
|
+
type: Injectable
|
|
375
|
+
}] });
|
|
376
|
+
function ProvideErrorHandler() {
|
|
377
|
+
return {
|
|
378
|
+
provide: ErrorHandler,
|
|
379
|
+
useClass: RxapErrorHandler,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function DefaultErrorCodeExtractor(error) {
|
|
384
|
+
return error.error?.code ?? null;
|
|
385
|
+
}
|
|
386
|
+
function DefaultErrorFilter(error) {
|
|
387
|
+
return error.status >= 400 && (!error.url || !/\/api\/status/.test(error.url));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function HttpErrorInterceptor(req, next) {
|
|
391
|
+
const anyHttpErrorService = inject(AnyHttpErrorService);
|
|
392
|
+
const messageHttpErrorService = inject(MessageHttpErrorService);
|
|
393
|
+
const codeHttpErrorService = inject(CodeHttpErrorService);
|
|
394
|
+
const options = inject(RXAP_ERROR_INTERCEPTOR_OPTIONS, { optional: true }) ?? {};
|
|
395
|
+
options.extractErrorCode ??= DefaultErrorCodeExtractor;
|
|
396
|
+
options.filter ??= [];
|
|
397
|
+
if (!options.filter.length) {
|
|
398
|
+
options.filter.push(DefaultErrorFilter);
|
|
399
|
+
}
|
|
400
|
+
return next(req).pipe(tap({
|
|
401
|
+
error: async (event) => {
|
|
402
|
+
if (event instanceof HttpErrorResponse) {
|
|
403
|
+
if (!options.filter?.some((filter) => filter(event))) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
let error = event.error;
|
|
407
|
+
if (event.error instanceof Blob) {
|
|
408
|
+
error = await event.error.text();
|
|
409
|
+
try {
|
|
410
|
+
error = JSON.parse(error);
|
|
411
|
+
}
|
|
412
|
+
catch (e) {
|
|
413
|
+
console.warn('error response object is not a json');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
const data = {
|
|
417
|
+
...SimplifyHttpErrorResponse(event),
|
|
418
|
+
method: req.method,
|
|
419
|
+
body: req.body,
|
|
420
|
+
timestamp: Date.now(),
|
|
421
|
+
};
|
|
422
|
+
if (typeof error === 'object') {
|
|
423
|
+
const errorCode = options.extractErrorCode(error);
|
|
424
|
+
if (errorCode) {
|
|
425
|
+
Sentry.captureMessage(`Error Code ${errorCode}`, {
|
|
426
|
+
level: 'warning',
|
|
427
|
+
contexts: ExtractContextFromError(error),
|
|
428
|
+
extra: ExtractExtraFromError(error),
|
|
429
|
+
tags: ExtractTagsFromError(error),
|
|
430
|
+
});
|
|
431
|
+
codeHttpErrorService.push({
|
|
432
|
+
...data,
|
|
433
|
+
errorCode,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
else if (event.error.message) {
|
|
437
|
+
messageHttpErrorService.push(data);
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
anyHttpErrorService.push(data);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
anyHttpErrorService.push(data);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
}));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// region message-http-error
|
|
452
|
+
// endregion
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Generated bundle index. Do not edit.
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
export { AnyHttpErrorComponent, AnyHttpErrorService, CodeHttpErrorComponent, CodeHttpErrorService, DefaultErrorCodeExtractor, DefaultErrorFilter, ErrorCaptureService, ErrorDialogComponent, ExtractContextFromError, ExtractError, ExtractExtraFromError, ExtractTagsFromError, HttpErrorInterceptor, MessageHttpErrorComponent, MessageHttpErrorService, PrintError, ProvideErrorHandler, RXAP_ERROR_DIALOG_COMPONENT, RXAP_ERROR_DIALOG_DATA, RXAP_ERROR_DIALOG_ERROR, RXAP_ERROR_HANDLER_OPTIONS, RXAP_ERROR_INTERCEPTOR_OPTIONS, RxapErrorHandler, SimplifyHttpErrorResponse };
|
|
459
|
+
//# sourceMappingURL=rxap-ngx-error.mjs.map
|