|
| 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