{"id":13468752,"url":"https://github.com/sindresorhus/electron-unhandled","last_synced_at":"2025-04-08T12:07:58.962Z","repository":{"id":43340868,"uuid":"91302707","full_name":"sindresorhus/electron-unhandled","owner":"sindresorhus","description":"Catch unhandled errors and promise rejections in your Electron app","archived":false,"fork":false,"pushed_at":"2024-05-24T16:07:48.000Z","size":28,"stargazers_count":453,"open_issues_count":9,"forks_count":24,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-01T10:17:58.738Z","etag":null,"topics":["electron","electron-module"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-15T06:30:24.000Z","updated_at":"2025-03-19T03:30:32.000Z","dependencies_parsed_at":"2024-11-14T00:27:21.467Z","dependency_job_id":"70403c68-f98b-45cf-843f-274e2f65721e","html_url":"https://github.com/sindresorhus/electron-unhandled","commit_stats":{"total_commits":39,"total_committers":10,"mean_commits":3.9,"dds":"0.23076923076923073","last_synced_commit":"9f2544f2c39c3585ea66fbe5ae838e9b2eb23078"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Felectron-unhandled","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Felectron-unhandled/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Felectron-unhandled/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Felectron-unhandled/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/electron-unhandled/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247838444,"owners_count":21004580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","electron-module"],"created_at":"2024-07-31T15:01:18.293Z","updated_at":"2025-04-08T12:07:58.944Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript","Library","Tools"],"sub_categories":["Uncategorized","For Electron"],"readme":"# electron-unhandled\n\n\u003e Catch unhandled errors and promise rejections in your [Electron](https://electronjs.org) app\n\nYou can use this module directly in both the main and renderer process.\n\n## Install\n\n```sh\nnpm install electron-unhandled\n```\n\n*Requires Electron 30 or later.*\n\n## Usage\n\n```js\nimport unhandled from 'electron-unhandled';\n\nunhandled();\n```\n\n## API\n\n### unhandled(options?)\n\nYou probably want to call this both in the `main` process and any `renderer` processes to catch all possible errors. \n\n**Note:** At minimum, this function must be called in the `main` process.\n\n### options\n\nType: `object`\n\nNote: Options can only be specified in the `main` process.\n\n#### logger\n\nType: `Function`\\\nDefault: `console.error`\n\nCustom logger that receives the error.\n\nCan be useful if you for example integrate with Sentry.\n\n#### showDialog\n\nType: `boolean`\\\nDefault: [Only in production](https://github.com/sindresorhus/electron-is-dev)\n\nPresent an error dialog to the user.\n\n\u003cimg src=\"screenshot.png\" width=\"532\"\u003e\n\n#### reportButton\n\nType: `Function`\\\nDefault: `undefined`\n\nWhen specified, the error dialog will include a `Report…` button, which when clicked, executes the given function with the error as the first argument.\n\n```js\nimport unhandled from 'electron-unhandled';\nimport {openNewGitHubIssue} from 'electron-util';\nimport {debugInfo} from 'electron-util/main';\n\nunhandled({\n\treportButton: error =\u003e {\n\t\topenNewGitHubIssue({\n\t\t\tuser: 'sindresorhus',\n\t\t\trepo: 'electron-unhandled',\n\t\t\tbody: `\n## Node.js error stack\n\n\\`\\`\\`\n${stack}\n\\`\\`\\`\n\n## Node.js debug info\n\n${debugInfo()}`\n\t\t});\n\t}\n});\n```\n\n[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)\n\n### logError(error, [options])\n\nLog an error. This does the same as with caught unhandled errors.\n\nIt will use the same options specified in the `unhandled()` call or the defaults.\n\n```js\nimport {logError} from 'electron-unhandled';\n\nlogError(new Error('🦄'));\n```\n\n#### error\n\nType: `Error`\n\nThe error to log.\n\n#### options\n\nType: `object`\n\n##### title\n\nType: `string`\\\nDefault: `${appName} encountered an error`\n\nThe title of the error dialog.\n\n## Related\n\n- [electron-store](https://github.com/sindresorhus/electron-store) - Save and load data like user settings, app state, cache, etc\n- [electron-debug](https://github.com/sindresorhus/electron-debug) - Adds useful debug features to your Electron app\n- [electron-context-menu](https://github.com/sindresorhus/electron-context-menu) - Context menu for your Electron app\n- [electron-dl](https://github.com/sindresorhus/electron-dl) - Simplified file downloads for your Electron app\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Felectron-unhandled","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Felectron-unhandled","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Felectron-unhandled/lists"}