Taitava / obsidian-shellcommands

Execute system commands via hotkeys or command palette in Obsidian (https://obsidian.md). Some automated events are also supported, and execution via URI links.
GNU General Public License v3.0
348 stars 11 forks source link

Bug: Output channel 'Open a file' causes an error in the console log if the file cannot be opened #176

Closed Taitava closed 2 years ago

Taitava commented 2 years ago

Error message:

Uncaught TypeError: Cannot read property 'then' of undefined
    at OutputChannelDriver_OpenFiles._handle (eval at <anonymous> (app.js:1), <anonymous>:1061:74)
    at OutputChannelDriver_OpenFiles.handle (eval at <anonymous> (app.js:1), <anonymous>:596:14)
    at handle_output (eval at <anonymous> (app.js:1), <anonymous>:908:47)
    at eval (eval at <anonymous> (app.js:1), <anonymous>:916:29)
    at HTMLButtonElement.<anonymous> (app.js:1)
_handle @ OutputChannelDriver_OpenFiles.ts:111
handle @ OutputChannelDriver.ts:52
handle_output @ OutputChannelDriver_Modal.ts:136
eval @ OutputChannelDriver_Modal.ts:145
(anonymous) @ app.js:1

It's because this else block does not return a promise, although it should: https://github.com/Taitava/obsidian-shellcommands/blob/5129dcfdd4c38d77c1962530dbd880ffe36f7c88/src/output_channels/OutputChannelDriver_OpenFiles.ts#L178-L181

Fix by adding the following line:

return Promise.reject();

Probably does not affect usability

I haven't noticed the plugin becoming unusable after this error, so I think there's no rush to release a fix, although I have implemented one already.

Taitava commented 2 years ago

Fixed and will be released in 0.12.0, or sooner if this turns out to affect users.

Taitava commented 2 years ago

Fix released.