(self, *, event: str, attempt: int, error: BaseException)
| 339 | } |
| 340 | |
| 341 | def _log_gateway_error(self, *, event: str, attempt: int, error: BaseException) -> None: |
| 342 | response = getattr(error, "response", None) |
| 343 | response_text = "" |
| 344 | if response is not None: |
| 345 | try: |
| 346 | response_text = str(getattr(response, "text", "") or "") |
| 347 | except Exception: |
| 348 | response_text = "" |
| 349 | if len(response_text) > 4000: |
| 350 | response_text = response_text[:4000] |
| 351 | |
| 352 | append_runtime_log( |
| 353 | self.config.error_log_path, |
| 354 | source=self._LOG_SOURCE, |
| 355 | event=event, |
| 356 | model_name=self.config.model_name, |
| 357 | endpoint=self._post_url(), |
| 358 | attempt=attempt, |
| 359 | error_type=type(error).__name__, |
| 360 | error=str(error), |
| 361 | status_code=getattr(response, "status_code", None), |
| 362 | response_text=response_text, |
| 363 | ) |
| 364 | |
| 365 | def _raw_response_log_path(self) -> Path | None: |
| 366 | if self.config.error_log_path is None: |
no test coverage detected