diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-08-11 18:11:26 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-08-11 18:11:26 -0300 |
commit | 1441e7784fda0356dfdea8f2ab360dbb506879f1 (patch) | |
tree | 7a8cae9159dc7c2731dfcd86e5708659bdd64592 /src/util | |
parent | ed719fabb9bc5a01db8c6ed051c03c388077b05c (diff) |
upd8: suppress only "didn't match anything" for sample ref errors
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/sugar.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/sugar.js b/src/util/sugar.js index c11024e1..487c093c 100644 --- a/src/util/sugar.js +++ b/src/util/sugar.js @@ -605,6 +605,20 @@ export function decorateErrorWithCause(fn, cause) { }; } +export function conditionallySuppressError(conditionFn, callbackFn) { + return (...args) => { + try { + return callbackFn(...args); + } catch (error) { + if (conditionFn(error, ...args) === true) { + return; + } + + throw error; + } + }; +} + // Delicious function annotations, such as: // // (*bound) soWeAreBackInTheMine |