(err error)
| 488 | } |
| 489 | |
| 490 | func getErrorResponse(err error) *responseError { |
| 491 | var apierr *anthropic.Error |
| 492 | if !errors.As(err, &apierr) { |
| 493 | return nil |
| 494 | } |
| 495 | |
| 496 | msg := apierr.Error() |
| 497 | typ := string(constant.ValueOf[constant.APIError]()) |
| 498 | |
| 499 | var detail *anthropic.APIErrorObject |
| 500 | if field, ok := apierr.JSON.ExtraFields["error"]; ok { |
| 501 | _ = json.Unmarshal([]byte(field.Raw()), &detail) |
| 502 | } |
| 503 | if detail != nil { |
| 504 | msg = detail.Message |
| 505 | typ = string(detail.Type) |
| 506 | } |
| 507 | |
| 508 | return &responseError{ |
| 509 | ErrorResponse: &anthropic.ErrorResponse{ |
| 510 | Error: anthropic.ErrorObjectUnion{ |
| 511 | Message: msg, |
| 512 | Type: typ, |
| 513 | }, |
| 514 | Type: constant.ValueOf[constant.Error](), |
| 515 | }, |
| 516 | StatusCode: apierr.StatusCode, |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | var _ error = &responseError{} |
| 521 |
no test coverage detected