Is it possible to have SSJS errors (like, eg, syntax errors) sent back to the browser?
It's a bit frustrating to get a "The page you requested is not available" error when the real error is "invalid syntax on line X".
Is it possible to have SSJS errors (like, eg, syntax errors) sent back to the browser?
It's a bit frustrating to get a "The page you requested is not available" error when the real error is "invalid syntax on line X".
If you have a wrong syntax in your ssjs script, the script execution will stop. That means there will be no way to send the error to the client. But you will have a log like this in the log output:
If this information is not detailed enough for you to understand what is going wrong, you are welcome to post the code to this forum. We might be able to tell you quickly what is going wrong.Code:1.19 JAPI plug error: RealityServer Error: /bla/test_applications/test/scripts/render.ssjs line 10: SyntaxError: syntax error 1.19 JAPI plug error: connection.print(() 1.19 JAPI plug error: ......................^
Hope that helps.
Last edited by ak; April 13th, 2010 at 11:59.
Err, sorry, yes - I have been using `tail -f .../server.log` to see errors… But this is less than entirely ideal because it means keeping an additional terminal open and ssh'd into the box running RealityServer.
Anyway, if there's no simple way of getting errors back to the browser, I guess I'll live with `tail`.
Thanks.
You are welcome.
For other problems than syntax errors you may use exception handling to inform the client about problems. A lot RS methods support exception handling and throw an exception when an error appears.
As an example you may have a look in tutorial bf8/scripts/updateWorls.ssjs (see RS distribution):
This is how the example application bf8 deals with server side errors when a user tries to modifying scene graph properties with unsupported types for example.Code:... try{ ... do some things ... } }catch(e){ loginfo('=> Exception: ' + e.toString()); sendToClient(e.toString()); } ... function sendToClient(text){ connection.response["Content-Type"] = "text/html"; connection.print(text); }...
Maybe this is useful for you.
Last edited by ak; April 13th, 2010 at 16:17.
Ah, ok - this is how I was planning on handling code errors, so thanks for confirming that it's correct![]()