Merge pull request #147 from jmorganca/brucemacd/cli-err-display

Improve CLI error display
This commit is contained in:
Bruce MacDonald
2023-07-21 16:10:19 +02:00
committed by GitHub
3 changed files with 22 additions and 11 deletions

View File

@@ -8,16 +8,23 @@ import (
)
type StatusError struct {
StatusCode int
Status string
Message string
StatusCode int
Status string
ErrorMessage string `json:"error"`
}
func (e StatusError) Error() string {
if e.Message != "" {
return fmt.Sprintf("%s: %s", e.Status, e.Message)
switch {
case e.Status != "" && e.ErrorMessage != "":
return fmt.Sprintf("%s: %s", e.Status, e.ErrorMessage)
case e.Status != "":
return e.Status
case e.ErrorMessage != "":
return e.ErrorMessage
default:
// this should not happen
return "something went wrong, please see the ollama server logs for details"
}
return e.Status
}
type GenerateRequest struct {