From eebebae518dc69bf88ce681e14a9e1229a737f69 Mon Sep 17 00:00:00 2001 From: rcmadhankumar Date: Thu, 19 Oct 2023 16:18:32 +0530 Subject: [PATCH] Status Error type conversion handled Signed-off-by: rcmadhankumar --- .../registry/datapackaging/package_storage_client.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/apiserver/registry/datapackaging/package_storage_client.go b/pkg/apiserver/registry/datapackaging/package_storage_client.go index 9cf2e2486..e6cb0643a 100644 --- a/pkg/apiserver/registry/datapackaging/package_storage_client.go +++ b/pkg/apiserver/registry/datapackaging/package_storage_client.go @@ -152,10 +152,14 @@ func (t PackageTranslator) ToExternalWatcher(intObjWatcher watch.Interface, fiel } func (t PackageTranslator) ToExternalError(err error) error { - statusErr := err.(*errors.StatusError) + statusErr, isStatusError := err.(*errors.StatusError) + if !isStatusError { + return err + } - if statusErr.ErrStatus.Details.Kind == "internalpackages" && statusErr.ErrStatus.Details.Group == internalpkgingv1alpha1.SchemeGroupVersion.Group { - packageName, err := t.ToExternalName(statusErr.ErrStatus.Details.Name) + details := statusErr.ErrStatus.Details + if details.Kind == "internalpackages" && details.Group == internalpkgingv1alpha1.SchemeGroupVersion.Group { + packageName, err := t.ToExternalName(details.Name) if err != nil { return err }