not found error before pulling model (#718)

This commit is contained in:
Bruce MacDonald 2023-10-06 16:06:20 -04:00 committed by GitHub
parent d6786f2945
commit af4cf55884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,8 +3,10 @@ package server
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/fs"
"log"
"net"
"net/http"
@ -170,6 +172,11 @@ func GenerateHandler(c *gin.Context) {
model, err := GetModel(req.Model)
if err != nil {
var pErr *fs.PathError
if errors.As(err, &pErr) {
c.JSON(http.StatusNotFound, gin.H{"error": fmt.Sprintf("model '%s' not found, try pulling it first", req.Model)})
return
}
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}