check if we do have an error before accessing response object functions