diff options
Diffstat (limited to 'src/common-util/sugar.js')
| -rw-r--r-- | src/common-util/sugar.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common-util/sugar.js b/src/common-util/sugar.js index 26f33c20..67083293 100644 --- a/src/common-util/sugar.js +++ b/src/common-util/sugar.js @@ -441,6 +441,15 @@ export function promiseWithResolvers() { return obj; } +export function errors(fn) { + try { + fn(); + return false; + } catch { + return true; + } +} + // Stolen from here: https://stackoverflow.com/a/3561711 // // There's a proposal for a native JS function like this, 8ut it's not even |