Normally, when making REST calls to an API with the Web Services module we return a useful response that you can use to initiate some logic around that call. You may get one of the many HTTP response codes as a result of one of these calls. Like a 200 code for Success or a 500 code for a Server Error. You can read more on the HTTP status codes at MDN here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
What do you do in the case of a connection timeout with the API? Presently, we do not handle those situations in the same manner as other responses. That’s because we don’t really get a response here, as we were not able to connect to the API.
We do have a workaround that can be implemented to catch such errors. It calls for a Try and Except block. Normally we would discourage the use of such a code block, as it can be too general if not configured properly. Therefore returning inconsistent results due to the broad scope of what it is trying to catch.
The following code example will only return an exception error code and message if there is an instance of GatewayException.