Reject instead of throw inside promise
This commit is contained in:
parent
1feac89c3b
commit
190d184f2a
4
main.ts
4
main.ts
|
@ -98,7 +98,7 @@ export default class NovelWordCountPlugin extends Plugin {
|
|||
// FUNCTIONALITY
|
||||
|
||||
private async getFileExplorerLeaf(): Promise<WorkspaceLeaf> {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let foundLeaf: WorkspaceLeaf | null = null;
|
||||
this.app.workspace.iterateAllLeaves((leaf) => {
|
||||
if (foundLeaf) {
|
||||
|
@ -115,7 +115,7 @@ export default class NovelWordCountPlugin extends Plugin {
|
|||
});
|
||||
|
||||
if (!foundLeaf) {
|
||||
throw new Error("Could not find file explorer leaf.");
|
||||
reject(Error("Could not find file explorer leaf."));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue