[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 16 deletions

View File

@ -7,7 +7,7 @@
# Add-on maintainers:
/bundles/org.openhab.automation.groovyscripting/ @wborn
/bundles/org.openhab.automation.jrubyscripting/ @boc-tothefuture
/bundles/org.openhab.automation.jsscripting/ @jpg0
/bundles/org.openhab.automation.jsscripting/ @jpg0 @florian-h05
/bundles/org.openhab.automation.jythonscripting/ @openhab/add-ons-maintainers
/bundles/org.openhab.automation.pidcontroller/ @fwolter
/bundles/org.openhab.automation.pwm/ @fwolter

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) {