[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:
parent
54e934be3d
commit
103619741d
@ -7,7 +7,7 @@
|
|||||||
# Add-on maintainers:
|
# Add-on maintainers:
|
||||||
/bundles/org.openhab.automation.groovyscripting/ @wborn
|
/bundles/org.openhab.automation.groovyscripting/ @wborn
|
||||||
/bundles/org.openhab.automation.jrubyscripting/ @boc-tothefuture
|
/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.jythonscripting/ @openhab/add-ons-maintainers
|
||||||
/bundles/org.openhab.automation.pidcontroller/ @fwolter
|
/bundles/org.openhab.automation.pidcontroller/ @fwolter
|
||||||
/bundles/org.openhab.automation.pwm/ @fwolter
|
/bundles/org.openhab.automation.pwm/ @fwolter
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
function stringify (value) {
|
function stringify (value) {
|
||||||
try {
|
try {
|
||||||
if (Java.isJavaObject(value)) {
|
if (Java.isJavaObject(value) || value instanceof Error) {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
} else {
|
} else {
|
||||||
// special cases
|
// special cases
|
||||||
@ -129,20 +129,8 @@
|
|||||||
log.error(format.apply(null, arguments));
|
log.error(format.apply(null, arguments));
|
||||||
},
|
},
|
||||||
|
|
||||||
trace: function (e) {
|
trace: function () {
|
||||||
if (Java.isJavaObject(e)) {
|
log.trace(new Error(format.apply(null, arguments)).stack.replace(/^Error: /, ''));
|
||||||
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'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
time: function (label) {
|
time: function (label) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user