Expose ErrResourceOwnerNotFound in err package (#3214)

<!-- PR description-->

Expose `ErrResourceOwnerNotFound` in `err` package to make for neat error handling

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #COR-74

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
zackrossman 2023-04-25 10:04:28 -07:00 committed by GitHub
parent 83e6803e3a
commit 51809cf6eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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() {