Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
server: organize error types (#9465)
CYJiang0bd0454ea7f5
diff --git a/server/download.go b/server/download.goindex 8f49351e4..6f79fd2d3 100644--- a/server/download.go+++ b/server/download.go@@ -29,8 +29,9 @@ import (const maxRetries = 6var (- errMaxRetriesExceeded = errors.New("max retries exceeded")- errPartStalled = errors.New("part stalled")+ errMaxRetriesExceeded = errors.New("max retries exceeded")+ errPartStalled = errors.New("part stalled")+ errMaxRedirectsExceeded = errors.New("maximum redirects exceeded (10) for directURL"))var blobDownloadManager sync.Map@@ -236,7 +237,7 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *regisnewOpts.CheckRedirect = func(req *http.Request, via []*http.Request) error {if len(via) > 10 {- return errors.New("maximum redirects exceeded (10) for directURL")+ return errMaxRedirectsExceeded}// if the hostname is the same, allow the redirectdiff --git a/server/images.go b/server/images.goindex 0c37613aa..290e68ba9 100644--- a/server/images.go+++ b/server/images.go@@ -35,6 +35,7 @@ var (errCapabilityCompletion = errors.New("completion")errCapabilityTools = errors.New("tools")errCapabilityInsert = errors.New("insert")+ errInsecureProtocol = errors.New("insecure protocol http"))type Capability string@@ -479,7 +480,7 @@ func PushModel(ctx context.Context, name string, regOpts *registryOptions, fn fufn(api.ProgressResponse{Status: "retrieving manifest"})if mp.ProtocolScheme == "http" && !regOpts.Insecure {- return errors.New("insecure protocol http")+ return errInsecureProtocol}manifest, _, err := GetManifest(mp)@@ -543,7 +544,7 @@ func PullModel(ctx context.Context, name string, regOpts *registryOptions, fn fu}if mp.ProtocolScheme == "http" && !regOpts.Insecure {- return errors.New("insecure protocol http")+ return errInsecureProtocol}fn(api.ProgressResponse{Status: "pulling manifest"})diff --git a/server/modelpath.go b/server/modelpath.goindex 5a96dec57..d1bcae93b 100644--- a/server/modelpath.go+++ b/server/modelpath.go@@ -31,9 +31,10 @@ const (var (ErrInvalidImageFormat = errors.New("invalid image format")+ ErrInvalidDigestFormat = errors.New("invalid digest format")ErrInvalidProtocol = errors.New("invalid protocol scheme")ErrInsecureProtocol = errors.New("insecure protocol http")- ErrInvalidDigestFormat = errors.New("invalid digest format")+ ErrModelPathInvalid = errors.New("invalid model path"))func ParseModelPath(name string) ModelPath {@@ -73,8 +74,6 @@ func ParseModelPath(name string) ModelPath {return mp}-var errModelPathInvalid = errors.New("invalid model path")-func (mp ModelPath) GetNamespaceRepository() string {return fmt.Sprintf("%s/%s", mp.Namespace, mp.Repository)}diff --git a/server/routes.go b/server/routes.goindex 059936249..92336af00 100644--- a/server/routes.go+++ b/server/routes.go@@ -777,7 +777,7 @@ func (s *Server) ShowHandler(c *gin.Context) {func GetModelInfo(req api.ShowRequest) (*api.ShowResponse, error) {name := model.ParseName(req.Model)if !name.IsValid() {- return nil, errModelPathInvalid+ return nil, ErrModelPathInvalid}name, err := getExistingName(name)if err != nil {