Display importFormatError on failed to parse input (#5809)
This commit is contained in:
parent
34533f62a9
commit
b734edba14
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue