From 17fe54bf0013dc86884b8efcaefa98bb9f32442a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morel=20Se=CC=81bastien?= Date: Fri, 22 Dec 2023 09:54:30 -0800 Subject: [PATCH] fix: reject an Error not a string --- .changeset/eleven-points-crash.md | 5 +++++ .../bootstrapper/utils/index.ts | 22 +++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 .changeset/eleven-points-crash.md diff --git a/.changeset/eleven-points-crash.md b/.changeset/eleven-points-crash.md new file mode 100644 index 0000000..db74de5 --- /dev/null +++ b/.changeset/eleven-points-crash.md @@ -0,0 +1,5 @@ +--- +'@crystallize/import-utilities': patch +--- + +reject an Error not a string diff --git a/src/bootstrap-tenant/bootstrapper/utils/index.ts b/src/bootstrap-tenant/bootstrapper/utils/index.ts index 6a962e9..f3732fb 100644 --- a/src/bootstrap-tenant/bootstrapper/utils/index.ts +++ b/src/bootstrap-tenant/bootstrapper/utils/index.ts @@ -61,14 +61,14 @@ export interface AreaWarning { export interface AreaError { message: string code: - | 'UPLOAD_FAILED' - | 'SHAPE_ID_MISSING' - | 'CANNOT_HANDLE_SHAPE' - | 'CANNOT_HANDLE_ITEM' - | 'CANNOT_HANDLE_PRODUCT' - | 'CANNOT_HANDLE_ITEM_RELATION' - | 'PARENT_FOLDER_NOT_FOUND' - | 'OTHER' + | 'UPLOAD_FAILED' + | 'SHAPE_ID_MISSING' + | 'CANNOT_HANDLE_SHAPE' + | 'CANNOT_HANDLE_ITEM' + | 'CANNOT_HANDLE_PRODUCT' + | 'CANNOT_HANDLE_ITEM_RELATION' + | 'PARENT_FOLDER_NOT_FOUND' + | 'OTHER' item?: JSONItem } @@ -233,10 +233,8 @@ export class FileUploadManager extends KillableWorker { } if (isLastAttempt) { - const msg = fileNotFound - ? `Got 404 for file "${item.url}"` - : e.message || JSON.stringify(e, null, 1) - item.reject?.(msg) + const msg = fileNotFound ? `Got 404 for file "${item.url}"` : e.message || JSON.stringify(e, null, 1) + item.reject?.(new Error(msg)) removeWorker(item) } else { item.failCount++