Merge pull request #83 from kzys/unimplemented

Return Unimplemented when services or methods are not implemented
This commit is contained in:
Phil Estes 2021-05-24 12:24:54 -04:00 committed by GitHub
commit 33729c89b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -136,7 +136,7 @@ func TestServer(t *testing.T) {
}
}
func TestServerNotFound(t *testing.T) {
func TestServerUnimplemented(t *testing.T) {
var (
ctx = context.Background()
server = mustServer(t)(NewServer())
@ -155,7 +155,7 @@ func TestServerNotFound(t *testing.T) {
t.Fatalf("expected error from non-existent service call")
} else if status, ok := status.FromError(err); !ok {
t.Fatalf("expected status present in error: %v", err)
} else if status.Code() != codes.NotFound {
} else if status.Code() != codes.Unimplemented {
t.Fatalf("expected not found for method")
}

View File

@ -116,12 +116,12 @@ func (s *serviceSet) dispatch(ctx context.Context, serviceName, methodName strin
func (s *serviceSet) resolve(service, method string) (Method, error) {
srv, ok := s.services[service]
if !ok {
return nil, status.Errorf(codes.NotFound, "service %v", service)
return nil, status.Errorf(codes.Unimplemented, "service %v", service)
}
mthd, ok := srv.Methods[method]
if !ok {
return nil, status.Errorf(codes.NotFound, "method %v", method)
return nil, status.Errorf(codes.Unimplemented, "method %v", method)
}
return mthd, nil