@messaia/cdk 22.0.1-rc.23 → 22.0.1-rc.25
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/fesm2022/messaia-cdk.mjs +51 -14
- package/fesm2022/messaia-cdk.mjs.map +1 -1
- package/package.json +1 -1
package/fesm2022/messaia-cdk.mjs
CHANGED
|
@@ -1587,6 +1587,13 @@ class BaseComponent {
|
|
|
1587
1587
|
if (errorCallback) {
|
|
1588
1588
|
errorCallback(errors);
|
|
1589
1589
|
}
|
|
1590
|
+
else {
|
|
1591
|
+
/* Provide visible feedback when the caller has no custom error handler */
|
|
1592
|
+
this.parseErrors(errors);
|
|
1593
|
+
if (this.errors.length) {
|
|
1594
|
+
this.showMessage(this.errors.join('\n'), MessageType.Error);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1590
1597
|
}
|
|
1591
1598
|
});
|
|
1592
1599
|
}
|
|
@@ -1898,6 +1905,25 @@ class BaseComponent {
|
|
|
1898
1905
|
this.errors = [];
|
|
1899
1906
|
this.isLoading = false;
|
|
1900
1907
|
this.isSaving = false;
|
|
1908
|
+
/* Unwrap HttpErrorResponse instances when request-level error handling is disabled */
|
|
1909
|
+
if (errors?.error != null) {
|
|
1910
|
+
errors = errors.error;
|
|
1911
|
+
}
|
|
1912
|
+
/* Keep plain error messages intact instead of iterating over their characters */
|
|
1913
|
+
if (typeof errors === 'string') {
|
|
1914
|
+
this.errors.push(errors);
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1917
|
+
/* Extract user-facing fields from RFC problem responses and ignore transport metadata */
|
|
1918
|
+
if (typeof errors?.title === 'string' || typeof errors?.detail === 'string') {
|
|
1919
|
+
if (typeof errors.title === 'string') {
|
|
1920
|
+
this.errors.push(errors.title);
|
|
1921
|
+
}
|
|
1922
|
+
if (typeof errors.detail === 'string' && errors.detail !== errors.title) {
|
|
1923
|
+
this.errors.push(errors.detail);
|
|
1924
|
+
}
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1901
1927
|
/* If there are errors, iterate through them and add them to the errors array */
|
|
1902
1928
|
if (errors) {
|
|
1903
1929
|
Object.keys(errors).forEach(el => {
|
|
@@ -15336,6 +15362,10 @@ class GenericService {
|
|
|
15336
15362
|
if (error.error instanceof ArrayBuffer) {
|
|
15337
15363
|
return JSON.parse(new TextDecoder().decode(new Uint8Array(error.error)));
|
|
15338
15364
|
}
|
|
15365
|
+
/* Preserve structured API errors such as ASP.NET ProblemDetails */
|
|
15366
|
+
if (error.error && typeof error.error === 'object') {
|
|
15367
|
+
return error.error;
|
|
15368
|
+
}
|
|
15339
15369
|
const message = (error.error instanceof ErrorEvent) ? error.error.message : `server returned code ${error.status} with body "${error.error}"`;
|
|
15340
15370
|
return `${operation} failed: ${message}`;
|
|
15341
15371
|
});
|
|
@@ -22423,19 +22453,13 @@ class BaseInterceptor {
|
|
|
22423
22453
|
if (req.headers.get('Show-Message')?.trim().toLowerCase() != 'yes') {
|
|
22424
22454
|
return;
|
|
22425
22455
|
}
|
|
22426
|
-
/* Handle validation errors for status code 400 (Bad Request) */
|
|
22427
|
-
if (error.status == 400) {
|
|
22428
|
-
let message = this.parseErrors(error.error);
|
|
22429
|
-
if (message) {
|
|
22430
|
-
this.snackBar.open(message, "OK", { duration: 8000, panelClass: ['error'] });
|
|
22431
|
-
}
|
|
22432
|
-
}
|
|
22433
22456
|
/* Handle permission errors for status code 403 (Forbidden) */
|
|
22434
22457
|
if (error.status == 403) {
|
|
22435
22458
|
this.snackBar.open($localize `:@@snackbar.error.not-allowed:You are not allowed to perform this request.`, undefined, {
|
|
22436
22459
|
duration: 6000,
|
|
22437
22460
|
panelClass: ['error']
|
|
22438
22461
|
});
|
|
22462
|
+
return;
|
|
22439
22463
|
}
|
|
22440
22464
|
/* Handle not found errors for status code 404 (Not Found) */
|
|
22441
22465
|
if (error.status == 404) {
|
|
@@ -22443,14 +22467,12 @@ class BaseInterceptor {
|
|
|
22443
22467
|
duration: 6000,
|
|
22444
22468
|
panelClass: ['error']
|
|
22445
22469
|
});
|
|
22470
|
+
return;
|
|
22446
22471
|
}
|
|
22447
|
-
/*
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
|
|
22451
|
-
/* Handle internal server errors for status code 500 */
|
|
22452
|
-
if (error.status == 500) {
|
|
22453
|
-
this.snackBar.open(error.text(), undefined, { duration: 6000, panelClass: ['error'] });
|
|
22472
|
+
/* Display structured API errors for every remaining HTTP status, including gateway errors */
|
|
22473
|
+
const message = this.parseErrors(error.error) || error.message;
|
|
22474
|
+
if (message) {
|
|
22475
|
+
this.snackBar.open(message, "OK", { duration: 8000, panelClass: ['error'] });
|
|
22454
22476
|
}
|
|
22455
22477
|
}));
|
|
22456
22478
|
}
|
|
@@ -22478,6 +22500,21 @@ class BaseInterceptor {
|
|
|
22478
22500
|
return "Failed to parse error details.";
|
|
22479
22501
|
}
|
|
22480
22502
|
}
|
|
22503
|
+
/* Keep plain response bodies intact */
|
|
22504
|
+
if (typeof error === 'string') {
|
|
22505
|
+
return error;
|
|
22506
|
+
}
|
|
22507
|
+
/* Extract user-facing fields from RFC Problem Details responses */
|
|
22508
|
+
const problem = error;
|
|
22509
|
+
if (typeof problem.title === 'string' || typeof problem.detail === 'string') {
|
|
22510
|
+
if (typeof problem.title === 'string') {
|
|
22511
|
+
errors.push(problem.title);
|
|
22512
|
+
}
|
|
22513
|
+
if (typeof problem.detail === 'string' && problem.detail !== problem.title) {
|
|
22514
|
+
errors.push(problem.detail);
|
|
22515
|
+
}
|
|
22516
|
+
return errors.join('\n');
|
|
22517
|
+
}
|
|
22481
22518
|
/* Ensure the error is an object (for structured error responses) */
|
|
22482
22519
|
if (typeof error === 'object') {
|
|
22483
22520
|
/* Iterate over the keys of the error object */
|