Handling API calls

What happens if the API does not return a value due to some error ?
what should we assume closing price as in such a case ?
or exception will be thrown is the expected outcome for this case ?

Could you please specify a case where the API doesn’t return a value and all parameters are correct?

1 Like

By making a Curl Command you can see whether the API requests that you are making are correct. When you know that your URL and other parameters are correct. Then you code it on java.

yes, I understand that.
I am just asking for a what if scenario, say the api call times out.
Or the test case has some name that the API does not have ?

There will be exceptions thrown in this case no doubt ?

So do we need to handle those exceptions or just let them propagate to main() ?

I am not saying all parameters will be correct
Parameters could be incorrect and that will be a negative test case.
and in such a case should we be handling the exception or just let it run through , is my question.

Also one such case could be when API call times out.

Something like this ->

There are two exceptions IOException and URIException. These two are enough to handle the negative test case that you are talking about. No need to throw any new Exception.

1 Like