added error handling returned by API call