Skip to content

Commit f351b12

Browse files
committed
fix possible panic
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
1 parent 1a06446 commit f351b12

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

aibridged/anthropic_utils.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@ func getAnthropicErrorResponse(err error) *AnthropicErrorResponse {
1515
}
1616

1717
msg := apierr.Error()
18+
typ := string(ant_constant.ValueOf[ant_constant.APIError]())
1819

1920
var detail *anthropic.BetaAPIError
2021
if field, ok := apierr.JSON.ExtraFields["error"]; ok {
2122
_ = json.Unmarshal([]byte(field.Raw()), &detail)
2223
}
2324
if detail != nil {
2425
msg = detail.Message
26+
typ = string(detail.Type)
2527
}
2628

2729
return &AnthropicErrorResponse{
2830
BetaErrorResponse: &anthropic.BetaErrorResponse{
2931
Error: anthropic.BetaErrorUnion{
3032
Message: msg,
31-
Type: string(detail.Type),
33+
Type: typ,
3234
},
3335
Type: ant_constant.ValueOf[ant_constant.Error](),
3436
},

0 commit comments

Comments
 (0)