electron-log
electron-log copied to clipboard
catchErrors ignores promise rejections
This may just be a documentation issue, but the catchError docs say:
Catch and log unhandled errors/rejected promises
Then the docs for the showDialog
option say:
Default true for the main process. Set it to false to prevent showing a default electron error dialog
I took these two items to mean that if showDialog
were set to true
, it would catch any unhandled exceptions and show an error dialog. However, I wasn't seeing the exception dialog and thought something was broken. After digging into the source, I see that Promise rejections are filtered out:
https://github.com/megahertz/electron-log/blob/bb2134889f74e856d32de0099c2f4c6c0d96409e/src/catchErrors.js#L37-L43
Looking through the history, it looks like the exclusion has been there since the catchErrors
feature has existed, so I don't think it just slipped in. However, I can't find any documentation as to why Promise rejections are being excluded. If they are deliberately being excluded, I think the documentation could benefit from calling that exclusion out.
As a workaround, I can use the onError
callback to handle Promise rejections, so it's not a big deal. I just think we can close a documentation gap here that might trip people up.
Thanks for pointing me out about the issue. An unhanded rejection is skipped because it follows the logic of Electron, when such an error is not displayed to a user. Maybe that behavior was changed in a newer version of Election, I haven't checked that. I'm going to check how it works in Electron in the latest version and then I'll make a decision whether I should change the code or add a note to documentation.
A related doc is updated, thank you