Display importFormatError on failed to parse input (#5809)

This commit is contained in:
Daniel James Smith 2023-07-25 01:07:44 +02:00 committed by GitHub
parent 34533f62a9
commit b734edba14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -108,7 +108,16 @@ export class ImportService implements ImportServiceAbstraction {
fileContents: string,
organizationId: string = null
): Promise<ImportResult> {
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);