1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

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

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);