Giter Site home page Giter Site logo

terrorizer1980 / electron-unhandled Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sindresorhus/electron-unhandled

0.0 1.0 0.0 88 KB

Catch unhandled errors and promise rejections in your Electron app

License: MIT License

JavaScript 95.10% TypeScript 4.90%

electron-unhandled's Introduction

electron-unhandled

Catch unhandled errors and promise rejections in your Electron app

You can use this module directly in both the main and renderer process.

Install

npm install electron-unhandled

Requires Electron 14 or later.

Usage

const unhandled = require('electron-unhandled');

unhandled();

API

unhandled(options?)

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.

options

Type: object

Note: Options can only be specified in the main process.

logger

Type: Function
Default: console.error

Custom logger that receives the error.

Can be useful if you for example integrate with Sentry.

showDialog

Type: boolean
Default: Only in production

Present an error dialog to the user.

reportButton

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.

const unhandled = require('electron-unhandled');
const {openNewGitHubIssue, debugInfo} = require('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.

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
Default: ${appName} encountered an error

The title of the error dialog.

Related

electron-unhandled's People

Contributors

armaldio avatar bendingbender avatar jmerle avatar raphinesse avatar richienb avatar sindresorhus avatar slapbox avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.