Merge pull request #1659 from micro/config-srv-not-found

Handle config service not found errors
This commit is contained in:
ben-toogood 2020-05-27 12:24:33 +01:00 committed by GitHub
commit 192f548c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,10 +2,12 @@ package service
import ( import (
"context" "context"
"net/http"
"github.com/micro/go-micro/v2/client" "github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/config/source" "github.com/micro/go-micro/v2/config/source"
proto "github.com/micro/go-micro/v2/config/source/service/proto" proto "github.com/micro/go-micro/v2/config/source/service/proto"
"github.com/micro/go-micro/v2/errors"
"github.com/micro/go-micro/v2/logger" "github.com/micro/go-micro/v2/logger"
) )
@ -29,7 +31,9 @@ func (m *service) Read() (set *source.ChangeSet, err error) {
Namespace: m.namespace, Namespace: m.namespace,
Path: m.path, Path: m.path,
}) })
if err != nil { if verr, ok := err.(*errors.Error); ok && verr.Code == http.StatusNotFound {
return nil, nil
} else if err != nil {
return nil, err return nil, err
} }