zek 14.2.71 → 14.2.73

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.createHandleErrorJson = (serviceName = '') => (operation = 'operation', show = true) => this.handleErrorJson(serviceName, operation, show);
1594
+ this.createHandleErrorResult = (serviceName = '') => (operation = 'operation', result = {}, show = true) => this.handleErrorResult(serviceName, operation, result, show);
1595
1595
  }
1596
1596
  /**
1597
1597
  * Returns a function that handles Http operation failures.
@@ -1607,10 +1607,45 @@ class HttpErrorHandler {
1607
1607
  if (show) {
1608
1608
  this.showError(serviceName, operation, response);
1609
1609
  }
1610
- //return throwError('Error! please try again later.');
1611
1610
  return of(result);
1612
1611
  };
1613
1612
  }
1613
+ /**
1614
+ * Returns a function that handles Http operation failures.
1615
+ * This error handler lets the app continue to run as if no error occurred.
1616
+ * @param serviceName = name of the data service that attempted the operation
1617
+ * @param operation - name of the operation that failed
1618
+ * @param show - optional value to show error
1619
+ */
1620
+ handleErrorResult(serviceName = '', operation = 'operation', result = {}, show) {
1621
+ return (response) => {
1622
+ console.error(response);
1623
+ if (show) {
1624
+ this.showError(serviceName, operation, response);
1625
+ }
1626
+ let error;
1627
+ if (typeof response.error === 'string' && response.error[0] === '{') {
1628
+ error = JSON.parse(response.error);
1629
+ }
1630
+ else {
1631
+ error = response.error;
1632
+ }
1633
+ let data;
1634
+ if (error instanceof ErrorEvent) {
1635
+ data = { '': [response.error.message] };
1636
+ }
1637
+ if (typeof error === 'string') {
1638
+ data = { '': [response.error] };
1639
+ }
1640
+ else if (typeof error === 'object') {
1641
+ const errors = error.traceId || error.success === false
1642
+ ? error.errors
1643
+ : error;
1644
+ data = errors;
1645
+ }
1646
+ return ObjectHelper.isDefined(data) ? of(data) : of(result);
1647
+ };
1648
+ }
1614
1649
  showError(serviceName, operation, response) {
1615
1650
  switch (response.status) {
1616
1651
  case 0: //No Connection
@@ -1684,42 +1719,6 @@ class HttpErrorHandler {
1684
1719
  break;
1685
1720
  }
1686
1721
  }
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
1722
  }
1724
1723
  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
1724
  HttpErrorHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: HttpErrorHandler });