mirror of
https://github.com/coalaura/whiskr.git
synced 2025-09-09 09:19:54 +00:00
improve error messages
This commit is contained in:
12
stream.go
12
stream.go
@@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/revrost/go-openrouter"
|
||||
)
|
||||
|
||||
type Chunk struct {
|
||||
@@ -65,6 +67,14 @@ func TextChunk(text string) Chunk {
|
||||
func ErrorChunk(err error) Chunk {
|
||||
return Chunk{
|
||||
Type: "error",
|
||||
Text: err.Error(),
|
||||
Text: GetErrorMessage(err),
|
||||
}
|
||||
}
|
||||
|
||||
func GetErrorMessage(err error) string {
|
||||
if apiErr, ok := err.(*openrouter.APIError); ok {
|
||||
return apiErr.Error()
|
||||
}
|
||||
|
||||
return err.Error()
|
||||
}
|
||||
|
Reference in New Issue
Block a user