Fix crash when script throws non-error object
This commit is contained in:
1 parent
a735f0d9e7
commit
480ae5efd6
1 file changed
+12
-5
+12
-5
@@ -243,18 +243,25 @@ function errorToFault(err) {
|
||||
if (!err)
|
||||
return null;
|
||||
|
||||
// Trim the stack trace at the self-executing anonymous wrapper function
|
||||
let stackTrimIndex = err.stack.match(/\s+at\s[^\s]+\s+at\s[^\s]+\s\(vm\.js.+\)/).index;
|
||||
if (!err.name)
|
||||
return {code: "script", message: `${err}`};
|
||||
|
||||
return {
|
||||
let fault = {
|
||||
code: `script.${err.name}`,
|
||||
message: err.message,
|
||||
detail: {
|
||||
name: err.name,
|
||||
message: err.message,
|
||||
stack: err.stack.slice(0, stackTrimIndex)
|
||||
message: err.message
|
||||
}
|
||||
};
|
||||
|
||||
if (err.stack) {
|
||||
// Trim the stack trace at the self-executing anonymous wrapper function
|
||||
let stackTrimIndex = err.stack.match(/\s+at\s[^\s]+\s+at\s[^\s]+\s\(vm\.js.+\)/).index;
|
||||
fault.detail.stack = err.stack.slice(0, stackTrimIndex);
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user