Return an object with 'error' set if API call results in an error