mirror of
https://github.com/aljazceru/ollama-free-model-proxy.git
synced 2025-12-18 21:44:20 +01:00
Somewhat better error handling.
This commit is contained in:
8
main.go
8
main.go
@@ -108,7 +108,10 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// Handle errors
|
// Handle errors
|
||||||
slog.Error("Stream error", "Error", err)
|
slog.Error("Stream error", "Error", err)
|
||||||
break
|
c.Status(http.StatusInternalServerError)
|
||||||
|
c.Writer.Write([]byte("Error streaming: " + err.Error() + "\n"))
|
||||||
|
c.Writer.Flush()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build JSON response structure
|
// Build JSON response structure
|
||||||
@@ -130,7 +133,8 @@ func main() {
|
|||||||
// Marshal and send the JSON response
|
// Marshal and send the JSON response
|
||||||
if err := json.NewEncoder(c.Writer).Encode(responseJSON); err != nil {
|
if err := json.NewEncoder(c.Writer).Encode(responseJSON); err != nil {
|
||||||
slog.Error("Error encoding response", "Error", err)
|
slog.Error("Error encoding response", "Error", err)
|
||||||
break
|
c.Status(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush data to send it immediately
|
// Flush data to send it immediately
|
||||||
|
|||||||
Reference in New Issue
Block a user