Skip to content

Commit b2fc281

Browse files
vinodf2fVinod Vijaykumar Yewatikar
andauthored
added patch for filter option in electron-unhabdled (#268)
Co-authored-by: Vinod Vijaykumar Yewatikar <[email protected]>
1 parent 07800ab commit b2fc281

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"main": "app/background.js",
1010
"scripts": {
1111
"dev": "nextron",
12-
"postinstall": "electron-builder install-app-deps",
12+
"postinstall": "electron-builder install-app-deps && patch-package",
1313
"build:mac": "nextron build --mac --x64",
1414
"build:win": "nextron build --win --x64",
1515
"build:linux": "nextron build --linux"
@@ -61,6 +61,7 @@
6161
"nextron": "^5.15.0",
6262
"opensubtitles-api": "^5.1.2",
6363
"parse-torrent-title": "^1.3.0",
64+
"patch-package": "^6.2.2",
6465
"plyr": "^3.6.2",
6566
"prettier": "^2.0.5",
6667
"pretty-bytes": "^5.3.0",
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
diff --git a/node_modules/electron-unhandled/index.d.ts b/node_modules/electron-unhandled/index.d.ts
2+
index 6231ad4..b5172f2 100644
3+
--- a/node_modules/electron-unhandled/index.d.ts
4+
+++ b/node_modules/electron-unhandled/index.d.ts
5+
@@ -1,31 +1,33 @@
6+
-declare namespace unhandled {
7+
+ declare namespace unhandled {
8+
interface UnhandledOptions {
9+
/**
10+
Custom logger that receives the error.
11+
-
12+
Can be useful if you for example integrate with Sentry.
13+
-
14+
@default console.error
15+
*/
16+
readonly logger?: (error: Error) => void;
17+
18+
/**
19+
Present an error dialog to the user.
20+
-
21+
Default: [Only in production](https://github.com/sindresorhus/electron-is-dev).
22+
*/
23+
readonly showDialog?: boolean;
24+
25+
+
26+
/**
27+
- When specified, the error dialog will include a `Report…` button, which when clicked, executes the given function with the error as the first argument.
28+
+ Filter option that receives an array of regex.
29+
+ electron-unhandled would not show the error dialog if error message passed by any of regex.
30+
+ @default []
31+
+ */
32+
+ readonly filter?: Array<RegExp>;
33+
34+
+ /**
35+
+ When specified, the error dialog will include a `Report…` button, which when clicked, executes the given function with the error as the first argument.
36+
@default undefined
37+
-
38+
@example
39+
```
40+
import unhandled = require('electron-unhandled');
41+
import {openNewGitHubIssue, debugInfo} = require('electron-util');
42+
-
43+
unhandled({
44+
reportButton: error => {
45+
openNewGitHubIssue({
46+
@@ -35,7 +37,6 @@ declare namespace unhandled {
47+
});
48+
}
49+
});
50+
-
51+
// 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
52+
```
53+
*/
54+
@@ -45,7 +46,6 @@ declare namespace unhandled {
55+
interface LogErrorOptions {
56+
/**
57+
Title of the error dialog.
58+
-
59+
@default `${appName} encountered an error`
60+
*/
61+
readonly title?: string;
62+
@@ -55,19 +55,16 @@ declare namespace unhandled {
63+
declare const unhandled: {
64+
/**
65+
Catch unhandled errors and promise rejections in your [Electron](https://electronjs.org) app.
66+
-
67+
You probably want to call this both in the main process and any renderer processes to catch all possible errors.
68+
*/
69+
(options?: unhandled.UnhandledOptions): void;
70+
71+
/**
72+
Log an error. This does the same as with caught unhandled errors.
73+
-
74+
It will use the same options specified in the `unhandled()` call or the defaults.
75+
-
76+
@param error - Error to log.
77+
*/
78+
logError(error: Error, options?: unhandled.LogErrorOptions): void;
79+
};
80+
81+
-export = unhandled;
82+
+export = unhandled
83+
\ No newline at end of file
84+
diff --git a/node_modules/electron-unhandled/index.js b/node_modules/electron-unhandled/index.js
85+
index 094955d..7ea7ed9 100644
86+
--- a/node_modules/electron-unhandled/index.js
87+
+++ b/node_modules/electron-unhandled/index.js
88+
@@ -17,11 +17,15 @@ let installed = false;
89+
90+
let options = {
91+
logger: console.error,
92+
- showDialog: !isDev
93+
+ showDialog: !isDev,
94+
+ filter: []
95+
};
96+
97+
const handleError = (title, error) => {
98+
error = ensureError(error);
99+
+ if (options.filter && options.filter.some(regex => regex.test(error.message))) {
100+
+ return;
101+
+ }
102+
103+
try {
104+
options.logger(error);

0 commit comments

Comments
 (0)