@@ -73,7 +73,7 @@ func (s *Server) Start(ctx context.Context) (*http.Server, error) {
7373 "cache_dir" : s .cache .Dir (),
7474 }).Info ("Starting server" )
7575 go func () {
76- if err := srv .Serve (ln ); err != nil && err != http .ErrServerClosed {
76+ if err := srv .Serve (ln ); err != nil && ! errors . Is ( err , http .ErrServerClosed ) {
7777 log .WithError (err ).Fatal ("Server error" )
7878 }
7979 }()
@@ -154,8 +154,7 @@ func (s *Server) imageHandler(w http.ResponseWriter, r *http.Request) {
154154 "image" : imageName ,
155155 }).WithError (err ).Error ("Failed to download image" )
156156 errorsTotalMetric .Inc ()
157- var notFound * ErrImageNotFound
158- if errors .As (err , & notFound ) {
157+ if notFound , match := errors.AsType [* ErrImageNotFound ](err ); match {
159158 writeJSONError (w , notFound .Error (), http .StatusNotFound )
160159 } else {
161160 writeJSONError (w , fmt .Sprintf ("failed to download image: %v" , err ), http .StatusInternalServerError )
@@ -177,8 +176,7 @@ func (s *Server) platformsHandler(w http.ResponseWriter, r *http.Request) {
177176 platforms , err := GetImagePlatforms (imageName )
178177 if err != nil {
179178 log .WithField ("image" , imageName ).WithError (err ).Error ("Failed to get platforms" )
180- var notFound * ErrImageNotFound
181- if errors .As (err , & notFound ) {
179+ if notFound , match := errors.AsType [* ErrImageNotFound ](err ); match {
182180 writeJSONError (w , notFound .Error (), http .StatusNotFound )
183181 } else {
184182 writeJSONError (w , fmt .Sprintf ("failed to get platforms: %v" , err ), http .StatusInternalServerError )
0 commit comments