From b734edba14c85eb8e41d9a375d2fed668e510f55 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Tue, 25 Jul 2023 01:07:44 +0200 Subject: [PATCH] Display importFormatError on failed to parse input (#5809) --- libs/importer/src/services/import.service.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/importer/src/services/import.service.ts b/libs/importer/src/services/import.service.ts index 8cfe40248c..07e9b998a4 100644 --- a/libs/importer/src/services/import.service.ts +++ b/libs/importer/src/services/import.service.ts @@ -108,7 +108,16 @@ export class ImportService implements ImportServiceAbstraction { fileContents: string, organizationId: string = null ): Promise { - const importResult = await importer.parse(fileContents); + let importResult: ImportResult; + try { + importResult = await importer.parse(fileContents); + } catch (error) { + if (error instanceof SyntaxError) { + throw new Error(this.i18nService.t("importFormatError")); + } + throw error; + } + if (!importResult.success) { if (!Utils.isNullOrWhitespace(importResult.errorMessage)) { throw new Error(importResult.errorMessage);