add logic for api errors.