Skip to content

Commit

Permalink
Add title option to unhandled.logError()
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 11, 2018
1 parent 76e4d12 commit 9a7ccfe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ let mainWindow;
mainWindow = new electron.BrowserWindow();
mainWindow.loadURL('https://google.com');

unhandled.logError(new Error('Test'));
unhandled.logError(new Error('Test'), {title: 'Custom Title'});
})();
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ module.exports = inputOptions => {
}
};

module.exports.logError = error => {
handleError(`${appName} encountered an error.`, error);
module.exports.logError = (error, options) => {
options = {
title: `${appName} encountered an error`,
...options
};

handleError(options.title, error);
};
19 changes: 18 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,29 @@ unhandled({

[Example of how the GitHub issue will look like.](https://github.com/sindresorhus/electron-unhandled/issues/new?body=%60%60%60%0AError%3A+Test%0A++++at+%2FUsers%2Fsindresorhus%2Fdev%2Foss%2Felectron-unhandled%2Fexample.js%3A27%3A21%0A%60%60%60%0A%0A---%0A%0AExample+1.1.0%0AElectron+3.0.8%0Adarwin+18.2.0%0ALocale%3A+en-US)

### unhandled.logError(error)
### unhandled.logError(error, [options])

Log an error. This does the same as with caught unhandled errors.

It will use the same options specified in the `unhandled()` call or the defaults.

#### error

Type: `Error`

Error to log.

#### options

Type: `Object`

##### title

Type: `string`<br>
Default: `${appName} encountered an error`

Title of the error dialog.


## Related

Expand Down

0 comments on commit 9a7ccfe

Please sign in to comment.