ToResponse marshals e into an *http.Response shaped for the OpenAI API.
()
| 63 | // ToResponse marshals e into an *http.Response shaped for the |
| 64 | // OpenAI API. |
| 65 | func (e *ResponseError) ToResponse() *http.Response { |
| 66 | body, err := json.Marshal(e) |
| 67 | if err != nil { |
| 68 | body = []byte(`{"error":{"type":"error","message":"error marshaling upstream error","code":"server_error"}}`) |
| 69 | } |
| 70 | return utils.NewJSONErrorResponse(e.StatusCode, e.RetryAfter, body) |
| 71 | } |
| 72 | |
| 73 | // ResponseErrorFromKeyPool translates a *keypool.Error into |
| 74 | // a developer-facing ResponseError shaped for the OpenAI API. |
no test coverage detected