use errors.Is
This commit is contained in:
parent
32dd67957d
commit
2de832552a
@ -629,11 +629,7 @@ func PullModel(ctx context.Context, name string, regOpts *registryOptions, fn fu
|
||||
return nil
|
||||
}
|
||||
|
||||
type ErrRemoteModelNotFound struct{}
|
||||
|
||||
func (ErrRemoteModelNotFound) Error() string {
|
||||
return "model not found"
|
||||
}
|
||||
var ErrRemoteModelNotFound = errors.New("model not found")
|
||||
|
||||
func pullModelManifest(ctx context.Context, mp ModelPath, regOpts *registryOptions) (*Manifest, error) {
|
||||
requestURL := mp.BaseURL().JoinPath("v2", mp.GetNamespaceRepository(), "manifests", mp.Tag)
|
||||
@ -643,7 +639,7 @@ func pullModelManifest(ctx context.Context, mp ModelPath, regOpts *registryOptio
|
||||
resp, err := makeRequestWithRetry(ctx, http.MethodGet, requestURL, headers, nil, regOpts)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
// The model was not found on the remote registry
|
||||
return nil, fmt.Errorf("%w: %s", ErrRemoteModelNotFound{}, err)
|
||||
return nil, fmt.Errorf("%w: %s", ErrRemoteModelNotFound, err)
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -592,8 +592,7 @@ func (s *Server) PullHandler(c *gin.Context) {
|
||||
defer cancel()
|
||||
|
||||
if err := PullModel(ctx, name.DisplayShortest(), regOpts, fn); err != nil {
|
||||
var e ErrRemoteModelNotFound
|
||||
if errors.As(err, &e) {
|
||||
if errors.Is(err, ErrRemoteModelNotFound) {
|
||||
hint := fmt.Sprintf("Model %q not found - please check the model name is correct and try again", reqName)
|
||||
if name.Host == DefaultRegistry {
|
||||
hint = fmt.Sprintf("Model %q not found - search available models at: https://ollama.com/search?q=%s", reqName, reqName)
|
||||
|
Loading…
x
Reference in New Issue
Block a user