Skip to content

Commit 759acd7

Browse files
committed
Fix handling uncaught exceptions or warnings that are not Error instances
1 parent 1bb8b8f commit 759acd7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/error/stack.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
// Retrieve `error.stack` by re-using the original error's stack trace
22
// Remove first line of `Error.stack` as it contains `Error.name|message`,
33
// which is already present in the upper error's `message`
4-
export const getStack = function({ stack = '' }) {
5-
return stack.replace(FIRST_LINE_REGEXP, '')
4+
export const getStack = function(mainValue) {
5+
if (!(mainValue instanceof Error)) {
6+
return ''
7+
}
8+
9+
return mainValue.stack.replace(FIRST_LINE_REGEXP, '')
610
}
711

812
const FIRST_LINE_REGEXP = /.*\n/u

0 commit comments

Comments
 (0)