pr comments
This commit is contained in:
parent
4d9568172d
commit
99ab9210ba
19
main.go
19
main.go
@ -14,20 +14,19 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checkErr prints the error message and exits the program if the message is not nil.
|
// checkErr prints the error message and exits the program if the message is not nil.
|
||||||
func checkErr(msg any) {
|
func checkErr(err any) {
|
||||||
if msg == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if errorResponse, ok := msg.(api.ErrorResponse); ok {
|
switch e := err.(type) {
|
||||||
// This error contains some additional information that we want to print
|
case api.ErrorResponse:
|
||||||
fmt.Fprintln(os.Stderr, "Error: ", errorResponse.Err)
|
fmt.Fprintln(os.Stderr, "Error: ", e.Err)
|
||||||
if errorResponse.Hint != "" {
|
if e.Hint != "" {
|
||||||
fmt.Fprintf(os.Stderr, "\n%s\n", errorResponse.Hint)
|
fmt.Fprintf(os.Stderr, "\n%s\n", e.Hint)
|
||||||
}
|
}
|
||||||
os.Exit(1)
|
default:
|
||||||
|
fmt.Fprintln(os.Stderr, "Error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintln(os.Stderr, "Error: ", msg)
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
@ -641,11 +641,10 @@ func pullModelManifest(ctx context.Context, mp ModelPath, regOpts *registryOptio
|
|||||||
headers := make(http.Header)
|
headers := make(http.Header)
|
||||||
headers.Set("Accept", "application/vnd.docker.distribution.manifest.v2+json")
|
headers.Set("Accept", "application/vnd.docker.distribution.manifest.v2+json")
|
||||||
resp, err := makeRequestWithRetry(ctx, http.MethodGet, requestURL, headers, nil, regOpts)
|
resp, err := makeRequestWithRetry(ctx, http.MethodGet, requestURL, headers, nil, regOpts)
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
// The model was not found on the remote registry
|
// 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
|
return nil, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user