Skip to content

Commit 80b538e

Browse files
authored
cli: catch upstream errors gracefully (ollama#11512)
1 parent 4f8a016 commit 80b538e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/cmd.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,14 @@ func chat(cmd *cobra.Command, opts runOptions) (*api.Message, error) {
11371137
if errors.Is(err, context.Canceled) {
11381138
return nil, nil
11391139
}
1140+
1141+
// this error should ideally be wrapped properly by the client
1142+
if strings.Contains(err.Error(), "upstream error") {
1143+
p.StopAndClear()
1144+
fmt.Println("An error occurred while processing your message. Please try again.")
1145+
fmt.Println()
1146+
return nil, nil
1147+
}
11401148
return nil, err
11411149
}
11421150

0 commit comments

Comments
 (0)