Skip to content

Commit

Permalink
fix: surface errors to user if bad frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinslin committed Jul 17, 2020
1 parent abcc367 commit 03107f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/engine-server/src/drivers/file/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export class FileStorage extends FileStorageBase implements DEngineStore {
files2Notes(fpaths: string[]): NoteRawProps[] {
const fp = new FileParser(this, { errorOnEmpty: false });
const data = fp.parse(fpaths);
const errors = fp.errors;
const badParseErrors = errors.filter((e) => e.status === "BAD_PARSE");
if (!_.isEmpty(badParseErrors)) {
throw Error(`bad yaml: ${badParseErrors}`)
}
return data.map((n) => n.toRawProps());
}

Expand Down
11 changes: 8 additions & 3 deletions packages/plugin-core/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ export class DendronWorkspace {
}
VSCodeUtils.openWS(path.join(rootDir, DENDRON_WS_NAME));
}


async reloadWorkspace(mainVault?: string) {
// TODO: dispose of existing workspace
Expand All @@ -585,9 +586,13 @@ export class DendronWorkspace {
mainVault = wsFolders![0].uri.fsPath;
}
const engine = DendronEngine.getOrCreateEngine({ root: mainVault });
await engine.init();
this._engine = engine;
return;
try {
await engine.init();
this._engine = engine;
return;
} catch (err) {
vscode.window.showErrorMessage(`error initializing dendron: ${JSON.stringify(err)}`);
}
}

/**
Expand Down

0 comments on commit 03107f4

Please sign in to comment.