router/service: handle not found error (#1770)

This commit is contained in:
ben-toogood 2020-07-01 10:18:19 +01:00 committed by GitHub
parent 58845d7012
commit a64078b5c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,10 +4,12 @@ import (
"context"
"fmt"
"io"
"net/http"
"sync"
"time"
"github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/errors"
"github.com/micro/go-micro/v2/router"
pb "github.com/micro/go-micro/v2/router/service/proto"
)
@ -226,8 +228,9 @@ func (s *svc) Lookup(q ...router.QueryOption) ([]router.Route, error) {
},
}, s.callOpts...)
// errored out
if err != nil {
if verr, ok := err.(*errors.Error); ok && verr.Code == http.StatusNotFound {
return nil, router.ErrRouteNotFound
} else if err != nil {
return nil, err
}