diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/sugar.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/sugar.js b/src/util/sugar.js index da21d6d0..c11024e1 100644 --- a/src/util/sugar.js +++ b/src/util/sugar.js @@ -594,6 +594,17 @@ export function decorateErrorWithIndex(fn) { }; } +export function decorateErrorWithCause(fn, cause) { + return (...args) => { + try { + return fn(...args); + } catch (error) { + error.cause = cause; + throw error; + } + }; +} + // Delicious function annotations, such as: // // (*bound) soWeAreBackInTheMine |