MCPcopy Create free account
hub / github.com/modelscope/modelscope / raise_on_error

Function raise_on_error

modelscope/hub/errors.py:171–186  ·  view source on GitHub ↗

If response error, raise exception Args: rsp (_type_): The server response Raises: RequestError: the response error message. Returns: bool: True if request is OK, otherwise raise `RequestError` exception.

(rsp)

Source from the content-addressed store, hash-verified

169
170
171def raise_on_error(rsp):
172 """If response error, raise exception
173
174 Args:
175 rsp (_type_): The server response
176
177 Raises:
178 RequestError: the response error message.
179
180 Returns:
181 bool: True if request is OK, otherwise raise `RequestError` exception.
182 """
183 if rsp['Code'] == HTTPStatus.OK:
184 return True
185 else:
186 raise RequestError(rsp['Message'])
187
188
189def datahub_raise_on_error(url, rsp, http_response: requests.Response):

Callers 1

_legacy_requestMethod · 0.90

Calls 1

RequestErrorClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…