auto-updater icon indicating copy to clipboard operation
auto-updater copied to clipboard

Uncaught exception thrown by parsePackageJson function

Open GThurler opened this issue 7 years ago • 1 comments

Hi there, great work with this module.

I've noticed using it that my application was crashing whenever I would check for updates on a branch that had an outdated package.json without the "auto-updater" field, and after some debugging found out there was an uncaught exception coming from your module, from the parsePackageJson function, in line 286.

if (!data['auto-updater']) {
    this.error('Invalid package.json. No auto-updater field', 'json.error');
    throw 'error';
}

The this.error call correctly emits the error event and prints the appropriate message, but the exception isn't handled anywhere and ends up crashing the application. Since all calls are asynchronous I can't really catch it from my application anywhere (at least from what I know).

Since there is a working error callback I don't particularly see a need to throw an exception, so I figured I'd ask if there's any deeper meaning or reason for it before submitting a PR removing the throw statement.

GThurler avatar May 09 '18 00:05 GThurler

Yes! Submit the PR. Thanks for that test case :)

juampi92 avatar May 09 '18 00:05 juampi92