Results 1 to 5 of 5

Thread: Sending SSJS errors to the browser?

  1. #1
    Join Date
    Mar 2010
    Posts
    52

    Default Sending SSJS errors to the browser?

    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".

  2. #2
    Join Date
    Jan 2007
    Location
    Berlin
    Posts
    789

    Default

    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:

    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: ......................^
    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.

    Hope that helps.
    Last edited by ak; April 13th, 2010 at 11:59.

  3. #3
    Join Date
    Mar 2010
    Posts
    52

    Default

    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.

  4. #4
    Join Date
    Jan 2007
    Location
    Berlin
    Posts
    789

    Default

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

    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); 
    }...
    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.

    Maybe this is useful for you.
    Last edited by ak; April 13th, 2010 at 16:17.

  5. #5
    Join Date
    Mar 2010
    Posts
    52

    Default

    Ah, ok - this is how I was planning on handling code errors, so thanks for confirming that it's correct

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •