@hmcts/ccd-case-ui-toolkit 7.0.2 → 7.0.3-error-message-fix

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.
@@ -12689,7 +12689,19 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
12689
12689
  if (0 === error.status || 502 === error.status) {
12690
12690
  return WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE;
12691
12691
  }
12692
- return error.error;
12692
+ let errorMsg = 'Error uploading file';
12693
+ if (error && error?.error) {
12694
+ const fullError = error.error;
12695
+ const start = fullError.indexOf('{');
12696
+ if (start >= 0) {
12697
+ const json = fullError.substring(start, fullError.length - 1).split('<EOL>').join('');
12698
+ const obj = JSON.parse(json);
12699
+ if (obj && obj?.error) {
12700
+ errorMsg = obj.error;
12701
+ }
12702
+ }
12703
+ }
12704
+ return errorMsg;
12693
12705
  }
12694
12706
  buildDocumentUploadData(selectedFile) {
12695
12707
  const documentUpload = new FormData();