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