How to handle connection issues

I am trying to capture connection issue and wonder if Katalon can handle them.

For example, if I send API request and connection is refused is there a way to capture that?

ResponseObject getTokenTestObject = WS.sendRequest(request)

Hello,
you need to check response header for return code … all is there in response.

Andrej Podhajský said:

Hello,
you need to check response header for return code … all is there in response.

Hi Andrej,

I know that I can validate response code with “WS.verifyResponseStatusCode”. Is there a way to capture “connection refused” error?

sorry i was not reading properly (only hour of sleep last night)

i would try to catch exception and check it like:

try{	response = WS.sendRequest(findTestObject('Object Repository/__Sandbox/rObject1'))} catch (Exception ce){	println '**********************************'	println ce	println '**********************************'}