MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _record_response_error

Function _record_response_error

uncommon_route/proxy.py:5254–5269  ·  view source on GitHub ↗
(response: Response, *, streaming: bool)

Source from the content-addressed store, hash-verified

5252 ))
5253
5254 def _record_response_error(response: Response, *, streaming: bool) -> None:
5255 body = getattr(response, "body", b"") or b""
5256 if not isinstance(body, (bytes, bytearray)):
5257 body = bytes(body)
5258 derived_error_code, derived_error_message = _extract_error_details(response.status_code, body)
5259 if derived_error_code == "spend_limit_exceeded":
5260 error_stage_value = "guardrail"
5261 else:
5262 error_stage_value = "upstream_response"
5263 _record_route_trace(
5264 status_code=response.status_code,
5265 streaming=streaming,
5266 error_code=derived_error_code,
5267 error_stage=error_stage_value,
5268 error_message=derived_error_message,
5269 )
5270
5271 # Tracks whether the streaming path has completed a record() call.
5272 # Needed because Starlette cancels the response generator when the

Callers 1

_handle_chat_coreFunction · 0.85

Calls 2

_extract_error_detailsFunction · 0.85
_record_route_traceFunction · 0.85

Tested by

no test coverage detected