diff --git a/pkg/core/localize/locales/en/cmd/context.en.toml b/pkg/core/localize/locales/en/cmd/context.en.toml index cd18408a86..b7c8cac819 100644 --- a/pkg/core/localize/locales/en/cmd/context.en.toml +++ b/pkg/core/localize/locales/en/cmd/context.en.toml @@ -274,6 +274,13 @@ Your instance might have been removed. You can update your context by creating a new instance or by using the "rhoas context set-kafka" command ''' +[context.common.error.namespace.notFound] +one=''' +Connector namespace in your context does not exist. +Your connector namespace might have been removed. +You can set a namespace in the current context by creating a new connector namespace or by using the "rhoas context set-namespace" command +''' + [context.common.error.context.notFound] one=''' context with name "{{.Name}}" does not exist diff --git a/pkg/shared/contextutil/util.go b/pkg/shared/contextutil/util.go index ec01ae9188..7c4db25c2e 100644 --- a/pkg/shared/contextutil/util.go +++ b/pkg/shared/contextutil/util.go @@ -2,12 +2,14 @@ package contextutil import ( "context" + "github.com/redhat-developer/app-services-cli/pkg/core/localize" "github.com/redhat-developer/app-services-cli/pkg/core/servicecontext" "github.com/redhat-developer/app-services-cli/pkg/shared/connection" "github.com/redhat-developer/app-services-cli/pkg/shared/factory" connectormgmtclient "github.com/redhat-developer/app-services-sdk-go/connectormgmt/apiv1/client" + connectorerror "github.com/redhat-developer/app-services-sdk-go/connectormgmt/apiv1/error" srsmgmtv1errors "github.com/redhat-developer/app-services-sdk-go/registrymgmt/apiv1/error" registrymgmtclient "github.com/redhat-developer/app-services-sdk-go/registrymgmt/apiv1/client" @@ -187,9 +189,14 @@ func GetNamespaceForServiceConfig(currCtx *servicecontext.ServiceConfig, conn *c namespace, _, err := (*conn).API().ConnectorsMgmt().ConnectorNamespacesApi.GetConnectorNamespace(f.Context, currCtx.NamespaceID).Execute() if err != nil { - return nil, err - } + if apiErr := connectorerror.GetAPIError(err); apiErr != nil { + if apiErr.GetCode() == connectorerror.ERROR_7 { + return nil, f.Localizer.MustLocalizeError("context.common.error.namespace.notFound") + } + return nil, err + } + } return &namespace, err }