Skip to content

Commit

Permalink
update http error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
seemywingz committed Dec 21, 2024
1 parent 17aa0b6 commit 05eee5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func chatCompletion(prompt string) string {

// Send the messages to OpenAI
res, err := ai.ChatCompletion(ponderMessages)
catchErr(err)
catchErr(err, "fatal")
ponderMessages = append(ponderMessages, goai.Message{
Role: "assistant",
Content: res.Choices[0].Message.Content,
Expand Down
5 changes: 3 additions & 2 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ func catchErr(err error, level ...string) {
lvl = level[0] // Use the provided level
}

fmt.Println("")
switch lvl {
case "warn":
fmt.Println("💔 Warning:", err)
fmt.Println("❗️", err)
case "fatal":
fmt.Println("💀 Fatal:", err)
fmt.Println("💀", err)
os.Exit(1)
}
}
Expand Down

0 comments on commit 05eee5d

Please sign in to comment.