Skip to content

Commit

Permalink
Require Electron 14
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Feb 13, 2022
1 parent 3220f09 commit 8ff49d4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
3 changes: 0 additions & 3 deletions .github/funding.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
9 changes: 7 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
declare namespace unhandled {
/**
__Note:__ Options can only be specified in the `main` process.
*/
interface UnhandledOptions {
/**
Custom logger that receives the error.
Expand Down Expand Up @@ -44,7 +47,7 @@ declare namespace unhandled {

interface LogErrorOptions {
/**
Title of the error dialog.
The title of the error dialog.
@default `${appName} encountered an error`
*/
Expand All @@ -56,7 +59,9 @@ declare const unhandled: {
/**
Catch unhandled errors and promise rejections in your [Electron](https://electronjs.org) app.
You probably want to call this both in the main process and any renderer processes to catch all possible errors.
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?: unhandled.UnhandledOptions): void;

Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ let invokeErrorHandler;

const ERROR_HANDLER_CHANNEL = 'electron-unhandled.ERROR';

const tryMakeSerialized = arg => {
const tryMakeSerialized = argument => {
try {
const serialized = serialize(arg);
const serialized = serialize(argument);
if (serialized) {
return serialized;
}
Expand All @@ -27,7 +27,7 @@ if (process.type === 'renderer') {
try {
await ipcRenderer.invoke(ERROR_HANDLER_CHANNEL, title, error);
return;
} catch (invokeError) {
} catch (invokeError) { // eslint-disable-line unicorn/catch-error-name
if (invokeError.message === 'An object could not be cloned.') {
// 1. If serialization failed, force the passed arg to an error format
error = ensureError(error);
Expand Down
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"description": "Catch unhandled errors and promise rejections in your Electron app",
"license": "MIT",
"repository": "sindresorhus/electron-unhandled",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"scripts": {
"start": "electron example.js",
Expand Down
24 changes: 10 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
You can use this module directly in both the main and renderer process.


## Install

```sh
npm install electron-unhandled
```
$ npm install electron-unhandled
```

*Requires Electron 7 or later.*

*Requires Electron 14 or later.*

## Usage

Expand All @@ -22,24 +20,23 @@ 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
**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
Note: Options can only be specified in the `main` process.

#### logger

Type: `Function`<br>
Type: `Function`\
Default: `console.error`

Custom logger that receives the error.
Expand All @@ -48,7 +45,7 @@ Can be useful if you for example integrate with Sentry.

#### showDialog

Type: `boolean`<br>
Type: `boolean`\
Default: [Only in production](https://github.com/sindresorhus/electron-is-dev)

Present an error dialog to the user.
Expand All @@ -57,7 +54,7 @@ Present an error dialog to the user.

#### reportButton

Type: `Function`<br>
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.
Expand Down Expand Up @@ -97,11 +94,10 @@ Type: `object`

##### title

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

Title of the error dialog.

The title of the error dialog.

## Related

Expand Down

0 comments on commit 8ff49d4

Please sign in to comment.