Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    handling rpc failure - help!

    Browser: any
    SmartClient Version: v8.2p_2012-06-06/PowerEdition Development Only (built 2012-06-06)

    I have a fetch call for a listgrid:

    Code:
          scJsObject.fetchData(null, 
                function(dsResponse, data) {(scJsObject.ID);
                  $wnd.alert('here');
                },
                {showPrompt:false,willHandleError:false});

    which fails within the completeResponse block of code on the server-side- so basically when I call rpcManager.send(dsRequest, dsResponse), our code that translates the json data throws an error. I can catch this and send a failure this way:

    Code:
    try{
            dsResponse.setSuccess();
            rpcManager.send(dsRequest, dsResponse);
            this.statistics.end(Statistics.ST_DATA_SOURCE_SEND);        
    } catch (Exception e) {
            dsResponse.setStatus(RPCResponse.STATUS_FAILURE);
            rpcManager.sendFailure(dsRequest, "Internal Error");
    }
    But I keep getting this error in the jsConsole: and the "loading" message continues to show in my listgrid. What is it that I am doing wrong?

    Code:
    14:44:27.128:XRP4:WARN:RPCManager:Error evaling structured RPC response: SyntaxError: invalid property id response text: [{//isc_RPCResponseStart-->[{data:"Internal 
    Error",invalidateCache:false,isDSResponse:true,status:-1}]
    I just want to tell the user that an error has occurred while trying to fetch the data. How do I do this properly?

    #2
    This is kind of an odd question - the response you're sending is obviously invalid JSON. Rather than worry about the client handling of this, shouldn't you just fix your code that generates this invalid response?

    Comment


      #3
      The error that we are throwing on the server-side is VALID to us. We want to catch it and tell the user by sending this message to the browser.

      Comment


        #4
        The problem is that you've already started writing a response at this point, it's too late to change the response to something else. This is analogous to the way the servlet API correctly disallows changing HTTP headers in the response once you've already started writing to the outputStream.

        So you need to catch this error earlier, or you need to make your code produce valid JSON even when it encounters an error, then handle this condition client-side in transformResponse by inspecting the dsResponse and substituting a DSResponse signalling an error.

        Comment


          #5
          Ok thank you

          Comment

          Working...
          X