diff --git a/cmd/minikube/cmd/service.go b/cmd/minikube/cmd/service.go index 321b7ccbc9..d138c73af3 100644 --- a/cmd/minikube/cmd/service.go +++ b/cmd/minikube/cmd/service.go @@ -104,7 +104,11 @@ var serviceCmd = &cobra.Command{ urls, err := service.WaitForService(api, namespace, svc, serviceURLTemplate, serviceURLMode, https, wait, interval) if err != nil { - exit.WithCodeT(exit.Data, `Error opening service: {{.error}}`, out.V{"error": err}) + if err.Error() == "Service not found in namespace" { + exit.WithCodeT(exit.Data, `Service '{{.service}}' was not found in '{{.namespace}}' namespace. +You may select another namespace by using 'minikube service {{.service}} -n '. Or list out all the services using 'minikube service list'`, out.V{"service": svc, "namespace": namespace}) + } + exit.WithError("Error opening service", err) } openURLs(svc, urls) diff --git a/pkg/minikube/service/service.go b/pkg/minikube/service/service.go index 6e9b6e97cf..d7ff77a37b 100644 --- a/pkg/minikube/service/service.go +++ b/pkg/minikube/service/service.go @@ -276,8 +276,7 @@ func WaitForService(api libmachine.API, namespace string, service string, urlTem chkSVC := func() error { return CheckService(namespace, service) } if err := retry.Expo(chkSVC, time.Duration(interval)*time.Second, time.Duration(wait)*time.Second); err != nil { - return urlList, errors.Errorf(`Service %s was not found in %q namespace. -You may select another namespace by using 'minikube service %s -n '. Or list out all the services using 'minikube service list'`, service, namespace, service) + return nil, errors.New("Service not found in namespace") } serviceURL, err := GetServiceURLsForService(api, namespace, service, urlTemplate)