consistent error handling for pull and generate

This commit is contained in:
Jeffrey Morgan
2023-07-10 21:34:15 -07:00
parent 407a5cabf4
commit a3ec1ec2a0
3 changed files with 42 additions and 111 deletions

View File

@@ -1,24 +1,5 @@
package api
import (
"fmt"
"net/http"
"strings"
)
type Error struct {
Code int32 `json:"code"`
Message string `json:"message"`
}
func (e Error) Error() string {
if e.Message == "" {
return fmt.Sprintf("%d %v", e.Code, strings.ToLower(http.StatusText(int(e.Code))))
}
return e.Message
}
type PullRequest struct {
Model string `json:"model"`
}
@@ -27,7 +8,6 @@ type PullProgress struct {
Total int64 `json:"total"`
Completed int64 `json:"completed"`
Percent float64 `json:"percent"`
Error Error `json:"error"`
}
type GenerateRequest struct {