Skip to content

Commit ab84e7e

Browse files
committed
error: return detailed error message for ns not found
This commit improves the error handling in case the namespace is not found. It returns more detailed message rather than just returning the error. Fixes: #1738 Signed-off-by: yati1998 <[email protected]>
1 parent c9970bd commit ab84e7e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

pkg/shared/contextutil/util.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package contextutil
22

33
import (
44
"context"
5+
56
"github.com/redhat-developer/app-services-cli/pkg/core/localize"
67
"github.com/redhat-developer/app-services-cli/pkg/core/servicecontext"
78

89
"github.com/redhat-developer/app-services-cli/pkg/shared/connection"
910
"github.com/redhat-developer/app-services-cli/pkg/shared/factory"
1011
connectormgmtclient "github.com/redhat-developer/app-services-sdk-go/connectormgmt/apiv1/client"
12+
connectorerror "github.com/redhat-developer/app-services-sdk-go/connectormgmt/apiv1/error"
1113
srsmgmtv1errors "github.com/redhat-developer/app-services-sdk-go/registrymgmt/apiv1/error"
1214

1315
registrymgmtclient "github.com/redhat-developer/app-services-sdk-go/registrymgmt/apiv1/client"
@@ -187,9 +189,14 @@ func GetNamespaceForServiceConfig(currCtx *servicecontext.ServiceConfig, conn *c
187189

188190
namespace, _, err := (*conn).API().ConnectorsMgmt().ConnectorNamespacesApi.GetConnectorNamespace(f.Context, currCtx.NamespaceID).Execute()
189191
if err != nil {
190-
return nil, err
191-
}
192+
if apiErr := connectorerror.GetAPIError(err); apiErr != nil {
193+
if apiErr.GetCode() == connectorerror.ERROR_7 {
194+
return nil, f.Localizer.MustLocalizeError("namespace.common.error.nameNotFound")
195+
}
192196

197+
return nil, err
198+
}
199+
}
193200
return &namespace, err
194201
}
195202

0 commit comments

Comments
 (0)