[jsscripting] Fix the console.trace polyfill to log a stack trace & Stringify JS Error (#13749)

* [jsscripting] Fix the `console.trace` polyfill to log a stack trace & Stringify JS `Error`
* [jsscripting] Add myself to the codeowners

Fixes #12646

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This commit is contained in:
Florian Hotze
2022-11-20 20:30:42 +01:00
committed by GitHub
parent 54e934be3d
commit 103619741d
2 changed files with 4 additions and 16 deletions

View File

@@ -19,7 +19,7 @@
function stringify (value) {
try {
if (Java.isJavaObject(value)) {
if (Java.isJavaObject(value) || value instanceof Error) {
return value.toString();
} else {
// special cases
@@ -129,20 +129,8 @@
log.error(format.apply(null, arguments));
},
trace: function (e) {
if (Java.isJavaObject(e)) {
log.trace(e.getLocalizedMessage(), e);
} else {
if (e.stack) {
log.trace(e.stack);
} else {
if (e.message) {
log.trace(format.apply(null, [(e.name || 'Error') + ':', e.message]));
} else {
log.trace((e.name || 'Error'));
}
}
}
trace: function () {
log.trace(new Error(format.apply(null, arguments)).stack.replace(/^Error: /, ''));
},
time: function (label) {