Skip to content

Commit

Permalink
improve errors
Browse files Browse the repository at this point in the history
  • Loading branch information
moelsayed committed Mar 14, 2024
1 parent 0cc2373 commit 55fed9e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/api/pkg/ee/clusterbackup/storage-location/provider.go
Expand Up @@ -30,10 +30,12 @@ import (
"fmt"

apiv2 "k8c.io/dashboard/v2/pkg/api/v2"
"k8c.io/dashboard/v2/pkg/handler/v1/common"
"k8c.io/dashboard/v2/pkg/provider"
"k8c.io/dashboard/v2/pkg/provider/kubernetes"
kubermaticv1 "k8c.io/kubermatic/v2/pkg/apis/kubermatic/v1"
"k8c.io/kubermatic/v2/pkg/resources"
utilerrors "k8c.io/kubermatic/v2/pkg/util/errors"

corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -97,7 +99,7 @@ func (p *BackupStorageProvider) Get(ctx context.Context, userInfo *provider.User
return &cbsl, nil
}
}
return nil, nil
return nil, utilerrors.NewNotFound("ClusterBackupStorageLocation", name)
}

func (p *BackupStorageProvider) Create(ctx context.Context, userInfo *provider.UserInfo, cbslName, projectID string, cbsl *kubermaticv1.ClusterBackupStorageLocation, credentials apiv2.S3BackupCredentials) (*kubermaticv1.ClusterBackupStorageLocation, error) {
Expand Down Expand Up @@ -140,7 +142,7 @@ func (p *BackupStorageProvider) Create(ctx context.Context, userInfo *provider.U
Key: "cloud-credentials",
}
if err := client.Create(ctx, cbsl); err != nil {
return nil, err
return nil, common.KubernetesErrorToHTTPError(err)
}
ownerReference := metav1.OwnerReference{
APIVersion: ownerReferenceApi,
Expand Down

0 comments on commit 55fed9e

Please sign in to comment.