@messaia/cdk 22.0.1-rc.24 → 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.
@@ -1905,6 +1905,10 @@ class BaseComponent {
1905
1905
  this.errors = [];
1906
1906
  this.isLoading = false;
1907
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
+ }
1908
1912
  /* Keep plain error messages intact instead of iterating over their characters */
1909
1913
  if (typeof errors === 'string') {
1910
1914
  this.errors.push(errors);
@@ -22449,19 +22453,13 @@ class BaseInterceptor {
22449
22453
  if (req.headers.get('Show-Message')?.trim().toLowerCase() != 'yes') {
22450
22454
  return;
22451
22455
  }
22452
- /* Handle validation errors for status code 400 (Bad Request) */
22453
- if (error.status == 400) {
22454
- let message = this.parseErrors(error.error);
22455
- if (message) {
22456
- this.snackBar.open(message, "OK", { duration: 8000, panelClass: ['error'] });
22457
- }
22458
- }
22459
22456
  /* Handle permission errors for status code 403 (Forbidden) */
22460
22457
  if (error.status == 403) {
22461
22458
  this.snackBar.open($localize `:@@snackbar.error.not-allowed:You are not allowed to perform this request.`, undefined, {
22462
22459
  duration: 6000,
22463
22460
  panelClass: ['error']
22464
22461
  });
22462
+ return;
22465
22463
  }
22466
22464
  /* Handle not found errors for status code 404 (Not Found) */
22467
22465
  if (error.status == 404) {
@@ -22469,14 +22467,12 @@ class BaseInterceptor {
22469
22467
  duration: 6000,
22470
22468
  panelClass: ['error']
22471
22469
  });
22470
+ return;
22472
22471
  }
22473
- /* Handle custom error message for status code 452 */
22474
- if (error.status == 452) {
22475
- this.snackBar.open(error.text(), undefined, { duration: 6000, panelClass: ['error'] });
22476
- }
22477
- /* Handle internal server errors for status code 500 */
22478
- if (error.status == 500) {
22479
- 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'] });
22480
22476
  }
22481
22477
  }));
22482
22478
  }
@@ -22504,6 +22500,21 @@ class BaseInterceptor {
22504
22500
  return "Failed to parse error details.";
22505
22501
  }
22506
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
+ }
22507
22518
  /* Ensure the error is an object (for structured error responses) */
22508
22519
  if (typeof error === 'object') {
22509
22520
  /* Iterate over the keys of the error object */