Error handling in GWS calls (STATUS)

In case of problem, the methods of GWS classes can throw an exception and set the STATUS variable with the appropriate error number.

By default, the program will stop if an exception is thrown. You can trap the GWS errors with a WHENEVER ERROR handler or with a TRY/CATCH block. In the next example, the readTextRequest() API is surrounded by a TRY/CATCH block:
DEFINE req com.HTTPServiceRequest,
       data STRING
...
LET req = com.WebServiceEngine.getHTTPServiceRequest(5)
...
TRY
   ...
   CALL req.readTextRequest() RETURNING data
   ...
CATCH
   CALL show_err(SFMT("Unexpected HTTP request read exception: %1", STATUS))
END TRY

For some errors, a human-readable description of the error code is available in the SQLCA.SQLERRM register.