The 4D ON ERR CALL() command allows developers to handle errors more elegantly. It gives the control over to the developers to handle the errors rather then letting 4D handle them. More information regarding the ON ERR CALL is located at: https://www.4d.com/docs/CMU/CMU00155.HTM. Here is a sample of the code:
ON ERR CALL("Amz_Error")
SET WEB SERVICE PARAMETER("BlobAsXMLIn";$1)
CALL WEB SERVICE("https://soap.amazon.com/onca/soap2";"https://soap.amazon.com";
"ActorSearchRequest";"https://soap.amazon.com";Web Service Manual )
GET WEB SERVICE RESULT($0;"BlobAsXMLOut";*) ` Memory clean-up on the final return value.
ON ERR CALL("")
errorMsg:= Get Web Service error info(1)
The ON ERR CALL() command works like this-The SOAP methods executes line by line skipping over the ON ERR CALL() command until it returns an error (soap fault). Once the error has been detected, the SOAP method jumps to the ON ERR CALL ("Amz_Error") command and executes the method that has been passed to the command to handle the error. Once that method has completed, it returns to the ON ERR CALL("") and continues at that particular line. To display the correct error message, use the Get Web Service error info command. This particular command returns the information about the last error encountered in the SOAP method. This allows you to display errors more elegantly.