API call return type and error handling
&quot;okay&quot; in programming often depends on context.
You chose to perform error handling by throwing exceptions, so there is no point in having a boolean return value - there will be no case where false is returned.
If you are asking whether it is better to return false rather than throw exception, that largely depends on the situation.
Your current error handling is already more granular than just success / failure - you want to detect different types of errors and respond differently, so the exception method is more appropriate.
Note that if you were to switch to return and maintain same granularity, you would need to use an Enum of possible results.
As for &quot;Is error handling ok&quot; - again, that depends.
How much 'some stuff' do you have around the API call?
What kind of stuff is it?
You may want to limit the amount of code in the catch block, and have separate catch blocks for other parts of code that may fail independently of any server errors.
Then again, how granular do you want to make your error handling?
Usually, the more precise the error and the more information user of the function has regarding why it failed the better, but if there are some constraints or type of errors that are not important they may be omitted, consolidated, or handled silently.