Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
electron-unhandled
Advanced tools
Catch unhandled errors and promise rejections in your Electron app
Catch unhandled errors and promise rejections in your Electron app
You can use this module directly in both the main and renderer process.
npm install electron-unhandled
Requires Electron 30 or later.
import unhandled from 'electron-unhandled';
unhandled();
You probably want to call this both in the main
process and any renderer
processes to catch all possible errors.
Note: At minimum, this function must be called in the main
process.
Type: object
Note: Options can only be specified in the main
process.
Type: Function
Default: console.error
Custom logger that receives the error.
Can be useful if you for example integrate with Sentry.
Type: boolean
Default: Only in production
Present an error dialog to the user.
Type: Function
Default: undefined
When specified, the error dialog will include a Report…
button, which when clicked, executes the given function with the error as the first argument.
import unhandled from 'electron-unhandled';
import {openNewGitHubIssue, debugInfo} from 'electron-util';
unhandled({
reportButton: error => {
openNewGitHubIssue({
user: 'sindresorhus',
repo: 'electron-unhandled',
body: `\`\`\`\n${error.stack}\n\`\`\`\n\n---\n\n${debugInfo()}`
});
}
});
Example of how the GitHub issue will look like.
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.
import {logError} from 'electron-unhandled';
logError(new Error('🦄'));
Type: Error
The error to log.
Type: object
Type: string
Default: ${appName} encountered an error
The title of the error dialog.
FAQs
Catch unhandled errors and promise rejections in your Electron app
The npm package electron-unhandled receives a total of 4,533 weekly downloads. As such, electron-unhandled popularity was classified as popular.
We found that electron-unhandled demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.