Skip to content

Commit

Permalink
feat: check claude's error response
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed Mar 10, 2024
1 parent 796be42 commit 1ea598c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion relay/util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ func ShouldDisableChannel(err *relaymodel.Error, statusCode int) bool {
if statusCode == http.StatusUnauthorized {
return true
}
if err.Type == "insufficient_quota" || err.Code == "invalid_api_key" || err.Code == "account_deactivated" {
switch err.Type {
case "insufficient_quota":
return true
// https://docs.anthropic.com/claude/reference/errors
case "authentication_error":
return true
case "permission_error":
return true
}
if err.Code == "invalid_api_key" || err.Code == "account_deactivated" {
return true
}
return false
Expand Down Expand Up @@ -101,6 +110,9 @@ func RelayErrorHandler(resp *http.Response) (ErrorWithStatusCode *relaymodel.Err
if err != nil {
return
}
if config.DebugEnabled {
logger.SysLog(fmt.Sprintf("error happened, status code: %d, response: \n%s", resp.StatusCode, string(responseBody)))
}
err = resp.Body.Close()
if err != nil {
return
Expand Down

0 comments on commit 1ea598c

Please sign in to comment.