Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line number missing for javascript errors #2913

Closed
cweiske opened this issue Dec 17, 2023 · 2 comments · Fixed by #2914
Closed

Line number missing for javascript errors #2913

cweiske opened this issue Dec 17, 2023 · 2 comments · Fixed by #2914

Comments

@cweiske
Copy link
Contributor

cweiske commented Dec 17, 2023

I updated Gerbera from 1.12.1 to current git master (bac67ef), had a strange bug with my kitchen radio, deleted all database tables and started gerbera. Now I get javascript errors all over the place:

error: Failed to execute script /etc/gerbera/import-cweiske.js: TypeError: cannot read property 'res' of undefined
error: [/usr/local/src/gerbera/gerbera-git/src/content/scripting/script.cc:430] void Script::_execute() Error: Script: failed to execute script

Unfortunately it does not tell me in which line the error occurs - this would be very helpful for debugging.
The stack trace would also help to see nesting.

https://duktape.org/api#duk_pcall

@cweiske
Copy link
Contributor Author

cweiske commented Dec 17, 2023

Replacing duk_safe_to_string with duk_safe_to_stacktrace gives better errors, and falls back to duk_safe_to_string if there is no stacktrace:

https://duktape.org/api#duk_to_stacktrace
If the argument is an object, the call looks up the argument's .stack property which becomes the result if the property value is a string. Otherwise the argument is replaced with duk_to_string(val) to ensure a string result.

Now I get:

error: Failed! to execute script /etc/gerbera/import-cweiske.js: TypeError: cannot read property 'res' of undefined
     at [anon] (duk_hobject_props.c:2621) internal
     at addImage (/usr/local/share/gerbera/js/common.js:998)
     at global (/etc/gerbera/import-cweiske.js:328) preventsyield
error: [/usr/local/src/gerbera/gerbera-git/src/content/scripting/script.cc:430] void Script::_execute() Error: Script: failed to execute script

cweiske added a commit to cweiske/gerbera that referenced this issue Dec 17, 2023
@KarlStraussberger
Copy link
Member

The fix is great.

There have been vast changes to the scripting mechanism. You may have to create a wrapper like https://github.com/gerbera/gerbera/blob/master/scripts%2Fjs%2Fimport.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants