I am attempting to display an error message on a VF page if I get a time out error from an api call. I am using try catch, to get to the exception, but I would like to stop further code execution after.
Controller:
try{
gmsSearchResults = GMSServiceAPI.doAdvancedSearch(cfg); //perform the call
}catch (CalloutException e){
if(e.getMessage() == 'Read timed out'){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.ERROR, ' We have a timeout Error. GMS did not return results for the allotted time.');
ApexPages.addMessage(myMsg);
}
}
if(gmsSearchResults.size() > 49){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.INFO, ' Search returned more than 50 records. Please refine your search criteria.');
ApexPages.addMessage(myMsg);
}
I am seeing the exception and the error in my debug log, but the rest of my code fails when it hits the if statement outside of the try/catch, with an error of "Attempt to de-reference a null object"