(err error)
| 620 | } |
| 621 | |
| 622 | func responseErrorFromAPIError(err error) *ResponseError { |
| 623 | var apierr *anthropic.Error |
| 624 | if !errors.As(err, &apierr) { |
| 625 | return nil |
| 626 | } |
| 627 | |
| 628 | msg := apierr.Error() |
| 629 | errType := string(constant.ValueOf[constant.APIError]()) |
| 630 | |
| 631 | var detail *anthropic.APIErrorObject |
| 632 | if field, ok := apierr.JSON.ExtraFields["error"]; ok { |
| 633 | _ = json.Unmarshal([]byte(field.Raw()), &detail) |
| 634 | } |
| 635 | if detail != nil { |
| 636 | msg = detail.Message |
| 637 | errType = string(detail.Type) |
| 638 | } |
| 639 | |
| 640 | return newResponseError(msg, errType, apierr.StatusCode, keypool.ParseRetryAfter(apierr.Response)) |
| 641 | } |
| 642 | |
| 643 | var _ error = &ResponseError{} |
| 644 |
no test coverage detected