Reject instead of throw inside promise

This commit is contained in:
Isaac Lyman 2022-03-09 13:39:28 -07:00
parent 1feac89c3b
commit 190d184f2a
1 changed files with 2 additions and 2 deletions

View File

@ -98,7 +98,7 @@ export default class NovelWordCountPlugin extends Plugin {
// FUNCTIONALITY // FUNCTIONALITY
private async getFileExplorerLeaf(): Promise<WorkspaceLeaf> { private async getFileExplorerLeaf(): Promise<WorkspaceLeaf> {
return new Promise((resolve) => { return new Promise((resolve, reject) => {
let foundLeaf: WorkspaceLeaf | null = null; let foundLeaf: WorkspaceLeaf | null = null;
this.app.workspace.iterateAllLeaves((leaf) => { this.app.workspace.iterateAllLeaves((leaf) => {
if (foundLeaf) { if (foundLeaf) {
@ -115,7 +115,7 @@ export default class NovelWordCountPlugin extends Plugin {
}); });
if (!foundLeaf) { if (!foundLeaf) {
throw new Error("Could not find file explorer leaf."); reject(Error("Could not find file explorer leaf."));
} }
}); });
} }