Handle config service not found errors

This commit is contained in:
Ben Toogood 2020-05-27 12:12:34 +01:00
parent f00b696282
commit bb5f2e5525

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 &source.ChangeSet{Data: []byte{}}, nil
} else if err != nil {
return nil, err return nil, err
} }