THROW ERROR FROM CRUD OPERATION - Forum - Mobile - Progress Community

THROW ERROR FROM CRUD OPERATION

 Forum

THROW ERROR FROM CRUD OPERATION

  • Is there anyway to throw an error on the appserver that can be retrieved by the mobile device? With invoke operations you can use the ReturnValue in the response object. It would be nice to let the mobile user know why an operation failed.

  • How about

       THROW NEW Progress.Lang.AppError("Problem with 'wibble'.").    ?

    Does the error message get returned to the client?  I'm reusing some existing REST services, but if I get an error back from the server, the error message is contained in the 'errorThrown' parameter of the failure event.

    Funnily enough, thinking about this has helped me solve something else, so thanks for that!

  • I can THROW the error just fine but I do not see anything on the mobile client. The mobile client thinks the service call was a success.

  • Hello.

    Are you doing the THROW from the CRUD method, something like "ReadCustomer" or "UpdateCustomer"?

    Here is how the code looks like in one of my test programs:

    ROUTINE-LEVEL ON ERROR UNDO, THROW.

    CLASS CustomerBE:

    ...

       METHOD PUBLIC VOID UpdateCustomer(INPUT-OUTPUT DATASET dsCustomer):    

           UNDO, THROW NEW Progress.Lang.AppError("Error message.").

           THIS-OBJECT:commitCustomers(INPUT "", ROW-MODIFIED).        

       END METHOD.

    ...

    Could you check that the network request returns HTTP error 500 with a request body like the following?

    {"_retVal":"Error message.","_errors":[{"_errorMsg":"ERROR condition: The Server application has returned an error. (7243) (7211)","_errorNum":0}]}

    I hope this helps.

  • Hello Edsel,

    I am throwing from CRUD method. Let me check the network request. Thanks.

  • Also, I have similar code to Edsels' in my Update. I then have the following code in my UpdateService's error handler and see error message in responseText object.

    /* input paramters are: jqXHR, textStatus */

    var msg = "";

    var msg = "";

    if (textStatus != undefined)

      msg = textStatus;

    if (jqXHR){    

      msg = msg + " Status :" + jqXHR.status;

      msg = msg + " responseText :" + jqXHR.responseText;

    }

    if (msg != undefined)

       alert("Update: " + msg);

    else

       alert("Update ERROR");

    console.log("CustomerUpdate ERROR" + msg);

  • You were both correct. I had a CATCH block in an include file that was catching the THROW on the appserver.

    Thanks