Skip to content

Commit

Permalink
fix: more error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
BigJk committed Sep 6, 2024
1 parent ded07d5 commit b59cfeb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rpc/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/BigJk/snd/rpc/bind"
"io"
"net/http"
"strings"
"time"

"github.com/BigJk/snd/database"
Expand Down Expand Up @@ -143,6 +144,10 @@ func RegisterAI(route *echo.Group, db database.Database) {
return "", err
}

if strings.HasPrefix("error code:", string(respBody)) {
return "", errors.New(string(respBody))
}

err = json.Unmarshal(respBody, &aiResp)
if err != nil {
return "", err
Expand Down

0 comments on commit b59cfeb

Please sign in to comment.