diff --git a/client/ollama/ollama.go b/client/ollama/ollama.go index 45b82126..06ee7fa2 100644 --- a/client/ollama/ollama.go +++ b/client/ollama/ollama.go @@ -74,11 +74,10 @@ func (c *Client) Run(ctx context.Context, ref string, messages []apitype.Message } type Error struct { - Status int `json:"-"` + Status int `json:"status"` Code string `json:"code"` Message string `json:"message"` Field string `json:"field,omitempty"` - RawBody []byte `json:"-"` } func (e *Error) Error() string { @@ -110,13 +109,10 @@ func Do[Res any](ctx context.Context, method, urlStr string, in any) (*Res, erro defer res.Body.Close() if res.StatusCode/100 != 2 { - var b bytes.Buffer - body := io.TeeReader(res.Body, &b) - e, err := decodeJSON[Error](body) + e, err := decodeJSON[Error](res.Body) if err != nil { return nil, err } - e.RawBody = b.Bytes() return nil, e } diff --git a/oweb/oweb.go b/oweb/oweb.go index f48e0496..352ba0c6 100644 --- a/oweb/oweb.go +++ b/oweb/oweb.go @@ -55,7 +55,8 @@ func Serve(h HandlerFunc, w http.ResponseWriter, r *http.Request) { if !errors.As(err, &oe) { oe = ErrInternal } - w.WriteHeader(cmp.Or(oe.Status, 400)) + oe.Status = cmp.Or(oe.Status, 400) + w.WriteHeader(oe.Status) if err := EncodeJSON(w, oe); err != nil { log.Printf("error encoding error: %v", err) }