MCPcopy Create free account
hub / github.com/coder/aibridge / getErrorResponse

Function getErrorResponse

intercept/messages/base.go:490–518  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

488}
489
490func 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
520var _ error = &responseError{}
521

Callers 2

ProcessRequestMethod · 0.70
ProcessRequestMethod · 0.70

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected