AnthonyMusgrove / Emby-ScripterX

Run custom external application or script (batch/bash/powershell/php/python/node.js/custom) on various events within the Emby Server.
https://emby-scripterx.com
76 stars 6 forks source link

Runtime errors in package js only logged if debug logging is enabled #36

Closed Slugger closed 4 years ago

Slugger commented 4 years ago

Describe the bug When an event handler fails, the error is only logged at the debug level. Errors are properly caught, but they should be logged at the error level so they are always present without the need for debug logging being turned on. I had a subtle syntax error in some js I was testing with and couldn't figure out why I wasn't seeing anything happening. Once I enabled debug logging, ScripterX printed out an error that lead me to my problem.

I don't know if JInt provides full stacktraces itself, but if it does, it would be great to log that along with the exception error message.

To Reproduce Steps to reproduce the behavior:

  1. Install a package
  2. Include a runtime error in the js code for your package
  3. Trigger the event handler to run
  4. Nothing in the log file unless you enable debug logging

Expected behavior When an error is caught, log it at error level instead of debug level so errors are always present in the log file to help with troubleshooting.

Screenshots n/a

Desktop (please complete the following information): n/a

Smartphone (please complete the following information): n/a

AnthonyMusgrove commented 4 years ago

No problems at all mate, this is now done.

Changed Debug level to Error level for any error except for 'function not implemented', and it will now include the entire exception stacktrace. It'll be up in the next release <3

Slugger commented 4 years ago

Confirmed working. I was hoping it would print a stacktrace of my JS code instead of a stacktrace of the C# invoker. But either way, it is dumping a stacktrace.

AnthonyMusgrove commented 4 years ago

No problems mate, I'm now catching JavaScriptException, and so far got it to the point of :

2020-06-17 22:38:49.432 Error Emby ScripterX: Package Javascript Error (8b91c4d0-66f2-47c8-9471-ae9c741d6b6f): 'ReferenceError: deliberate_error is not defined' on line 69 of C:\Users\Anthony\AppData\Roaming\Emby-Server\programdata\data/ScripterX/Packages/8b91c4d0-66f2-47c8-9471-ae9c741d6b6f/Package.js. Data:

Just looking at what else it provides that would be useful and then I'll include it in the release :)