diff --git a/packages/common/error.js b/packages/common/error.js index 353a4a1763ade6b97a578ca2f796e0c6c049dd6e..e69f158d5a39ac69807b76d943d0bf2d045ae4d6 100644 --- a/packages/common/error.js +++ b/packages/common/error.js @@ -132,3 +132,14 @@ export const errorMixin = { } } }; + +/** + * Returns the stack trace as array + * + * @returns {string[]} + */ +export const getStackTrace = () => { + let stack = new Error().stack || ''; + stack = stack.split('\n').map(function (line) { return line.trim(); }); + return stack.splice(stack[0] === 'Error' ? 2 : 1); +}