code: def check_error(res, error_enum):
    
    if res.HasField("error"):
      enum_name = error_enum.DESCRIPTOR.full_name
      error_name = error_enum.Name(res.error)
      details = getattr(res, "error_details", "<none>")
      raise RequestError("%s.%s: '%s'" % (enum_name, error_name, details), res)
    return res
docs: Raise if the result has an error, otherwise return the result.