zek 14.2.71 → 14.2.72
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/fesm2020/zek.mjs
CHANGED
|
@@ -1591,7 +1591,7 @@ class HttpErrorHandler {
|
|
|
1591
1591
|
this.router = router;
|
|
1592
1592
|
/** Create curried handleError function that already knows the service name */
|
|
1593
1593
|
this.createHandleError = (serviceName = '') => (operation = 'operation', result = {}, show = true) => this.handleError(serviceName, operation, result, show);
|
|
1594
|
-
this.
|
|
1594
|
+
this.createHandleErrorResult = (serviceName = '') => (operation = 'operation', show = true) => this.handleErrorResult(serviceName, operation, show);
|
|
1595
1595
|
}
|
|
1596
1596
|
/**
|
|
1597
1597
|
* Returns a function that handles Http operation failures.
|
|
@@ -1611,6 +1611,42 @@ class HttpErrorHandler {
|
|
|
1611
1611
|
return of(result);
|
|
1612
1612
|
};
|
|
1613
1613
|
}
|
|
1614
|
+
/**
|
|
1615
|
+
* Returns a function that handles Http operation failures.
|
|
1616
|
+
* This error handler lets the app continue to run as if no error occurred.
|
|
1617
|
+
* @param serviceName = name of the data service that attempted the operation
|
|
1618
|
+
* @param operation - name of the operation that failed
|
|
1619
|
+
* @param show - optional value to show error
|
|
1620
|
+
*/
|
|
1621
|
+
handleErrorResult(serviceName = '', operation = 'operation', show) {
|
|
1622
|
+
return (response) => {
|
|
1623
|
+
console.error(response);
|
|
1624
|
+
if (show) {
|
|
1625
|
+
this.showError(serviceName, operation, response);
|
|
1626
|
+
}
|
|
1627
|
+
let error;
|
|
1628
|
+
if (typeof response.error === 'string' && response.error[0] === '{') {
|
|
1629
|
+
error = JSON.parse(response.error);
|
|
1630
|
+
}
|
|
1631
|
+
else {
|
|
1632
|
+
error = response.error;
|
|
1633
|
+
}
|
|
1634
|
+
let result;
|
|
1635
|
+
if (error instanceof ErrorEvent) {
|
|
1636
|
+
result = { '': [response.error.message] };
|
|
1637
|
+
}
|
|
1638
|
+
if (typeof error === 'string') {
|
|
1639
|
+
result = { '': [response.error] };
|
|
1640
|
+
}
|
|
1641
|
+
else if (typeof error === 'object') {
|
|
1642
|
+
const errors = error.traceId || error.success === false
|
|
1643
|
+
? error.errors
|
|
1644
|
+
: error;
|
|
1645
|
+
result = errors;
|
|
1646
|
+
}
|
|
1647
|
+
return of(result);
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1614
1650
|
showError(serviceName, operation, response) {
|
|
1615
1651
|
switch (response.status) {
|
|
1616
1652
|
case 0: //No Connection
|
|
@@ -1684,42 +1720,6 @@ class HttpErrorHandler {
|
|
|
1684
1720
|
break;
|
|
1685
1721
|
}
|
|
1686
1722
|
}
|
|
1687
|
-
/**
|
|
1688
|
-
* Returns a function that handles Http operation failures.
|
|
1689
|
-
* This error handler lets the app continue to run as if no error occurred.
|
|
1690
|
-
* @param serviceName = name of the data service that attempted the operation
|
|
1691
|
-
* @param operation - name of the operation that failed
|
|
1692
|
-
* @param show - optional value to show error
|
|
1693
|
-
*/
|
|
1694
|
-
handleErrorJson(serviceName = '', operation = 'operation', show) {
|
|
1695
|
-
return (response) => {
|
|
1696
|
-
console.error(response);
|
|
1697
|
-
if (show) {
|
|
1698
|
-
this.showError(serviceName, operation, response);
|
|
1699
|
-
}
|
|
1700
|
-
let error;
|
|
1701
|
-
if (typeof response.error === 'string' && response.error[0] === '{') {
|
|
1702
|
-
error = JSON.parse(response.error);
|
|
1703
|
-
}
|
|
1704
|
-
else {
|
|
1705
|
-
error = response.error;
|
|
1706
|
-
}
|
|
1707
|
-
let result;
|
|
1708
|
-
if (error instanceof ErrorEvent) {
|
|
1709
|
-
result = { '': [response.error.message] };
|
|
1710
|
-
}
|
|
1711
|
-
if (typeof error === 'string') {
|
|
1712
|
-
result = { '': [response.error] };
|
|
1713
|
-
}
|
|
1714
|
-
else if (typeof error === 'object') {
|
|
1715
|
-
const errors = error.traceId || error.success === false
|
|
1716
|
-
? error.errors
|
|
1717
|
-
: error;
|
|
1718
|
-
result = errors;
|
|
1719
|
-
}
|
|
1720
|
-
return of(result);
|
|
1721
|
-
};
|
|
1722
|
-
}
|
|
1723
1723
|
}
|
|
1724
1724
|
HttpErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: HttpErrorHandler, deps: [{ token: AlertService }, { token: i1$1.TranslateService }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1725
1725
|
HttpErrorHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: HttpErrorHandler });
|