Skip to content

Commit

Permalink
Handle sql.ErrNoRows in CheckModelAccess and respond with error m…
Browse files Browse the repository at this point in the history
…essage. (#524)
  • Loading branch information
swuecho authored Sep 8, 2024
1 parent 1dde723 commit 85a74e8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/chat_main_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@ func (h *ChatHandler) CheckModelAccess(w http.ResponseWriter, chatSessionUuid st
Model: rate.ChatModelName,
})

if err != nil {
// no rows
if errors.Is(err, sql.ErrNoRows) {
RespondWithError(w, http.StatusInternalServerError, "error.fail_to_get_rate_limit", err)
return true
}
RespondWithError(w, http.StatusInternalServerError, "error.fail_to_get_rate_limit", err)
return true
}

log.Printf("%+v", usage10Min)

if int32(usage10Min) > rate.RateLimit {
Expand Down

0 comments on commit 85a74e8

Please sign in to comment.