From 51809cf6eb064736e36afa2aec678df45ade72a6 Mon Sep 17 00:00:00 2001 From: zackrossman <117101895+zackrossman@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:04:28 -0700 Subject: [PATCH] Expose ErrResourceOwnerNotFound in err package (#3214) Expose `ErrResourceOwnerNotFound` in `err` package to make for neat error handling #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [x] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Issue(s) * #COR-74 #### Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- src/pkg/errs/err.go | 14 ++++++++------ src/pkg/errs/errs_test.go | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pkg/errs/err.go b/src/pkg/errs/err.go index fc8158390..fe53a218c 100644 --- a/src/pkg/errs/err.go +++ b/src/pkg/errs/err.go @@ -13,18 +13,20 @@ import ( type errEnum string const ( - RepoAlreadyExists errEnum = "repository-already-exists" - BackupNotFound errEnum = "backup-not-found" - ServiceNotEnabled errEnum = "service-not-enabled" + RepoAlreadyExists errEnum = "repository-already-exists" + BackupNotFound errEnum = "backup-not-found" + ServiceNotEnabled errEnum = "service-not-enabled" + ResourceOwnerNotFound errEnum = "resource-owner-not-found" ) // map of enums to errors. We might want to re-use an enum for multiple // internal errors (ex: "ServiceNotEnabled" may exist in both graph and // non-graph producers). var internalToExternal = map[errEnum][]error{ - RepoAlreadyExists: {repository.ErrorRepoAlreadyExists}, - BackupNotFound: {repository.ErrorBackupNotFound}, - ServiceNotEnabled: {graph.ErrServiceNotEnabled}, + RepoAlreadyExists: {repository.ErrorRepoAlreadyExists}, + BackupNotFound: {repository.ErrorBackupNotFound}, + ServiceNotEnabled: {graph.ErrServiceNotEnabled}, + ResourceOwnerNotFound: {graph.ErrResourceOwnerNotFound}, } // Is checks if the provided error contains an internal error that matches diff --git a/src/pkg/errs/errs_test.go b/src/pkg/errs/errs_test.go index 6c854f31b..43d718f7c 100644 --- a/src/pkg/errs/errs_test.go +++ b/src/pkg/errs/errs_test.go @@ -27,6 +27,7 @@ func (suite *ErrUnitSuite) TestIs() { {RepoAlreadyExists, repository.ErrorRepoAlreadyExists}, {BackupNotFound, repository.ErrorBackupNotFound}, {ServiceNotEnabled, graph.ErrServiceNotEnabled}, + {ResourceOwnerNotFound, graph.ErrResourceOwnerNotFound}, } for _, test := range table { suite.Run(string(test.is), func() {