From 45b84c95129de5f4bcf7f8c1e013d23ca9b9f136 Mon Sep 17 00:00:00 2001 From: Edgar Lee Date: Thu, 14 Jul 2016 15:03:18 -0700 Subject: [PATCH] Use typecast over reflect for error type checking Signed-off-by: Edgar Lee --- registry/handlers/catalog.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/handlers/catalog.go b/registry/handlers/catalog.go index 083ebfd0..4e95bfb0 100644 --- a/registry/handlers/catalog.go +++ b/registry/handlers/catalog.go @@ -6,7 +6,6 @@ import ( "io" "net/http" "net/url" - "reflect" "strconv" "github.com/docker/distribution/registry/api/errcode" @@ -48,8 +47,9 @@ func (ch *catalogHandler) GetCatalog(w http.ResponseWriter, r *http.Request) { repos := make([]string, maxEntries) filled, err := ch.App.registry.Repositories(ch.Context, repos, lastEntry) + _, pathNotFound := err.(driver.PathNotFoundError) - if err == io.EOF || reflect.TypeOf(err) == reflect.TypeOf(driver.PathNotFoundError{}) { + if err == io.EOF || pathNotFound { moreEntries = false } else if err != nil && err != storage.ErrFinishedWalk { ch.Errors = append(ch.Errors, errcode.ErrorCodeUnknown.WithDetail(err))