Minor refactoring of graph error checking code (#3686)
Minor code cleanup to error checking and calling code: - Remove unused function - Update error check for folder not found - Remove duplicate check in SDK function --- #### 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 - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * fixes #3684 #### Test Plan - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
d9f6a9297f
commit
dcf02f6256
@ -131,7 +131,9 @@ func IsErrQuotaExceeded(err error) bool {
|
||||
}
|
||||
|
||||
func IsErrExchangeMailFolderNotFound(err error) bool {
|
||||
return hasErrorCode(err, ResourceNotFound, MailboxNotEnabledForRESTAPI)
|
||||
// Not sure if we can actually see a resourceNotFound error here. I've only
|
||||
// seen the latter two.
|
||||
return hasErrorCode(err, ResourceNotFound, itemNotFound, MailboxNotEnabledForRESTAPI)
|
||||
}
|
||||
|
||||
func IsErrUserNotFound(err error) bool {
|
||||
@ -153,10 +155,6 @@ func IsErrUserNotFound(err error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func IsErrResourceNotFound(err error) bool {
|
||||
return hasErrorCode(err, ResourceNotFound)
|
||||
}
|
||||
|
||||
func IsErrCannotOpenFileAttachment(err error) bool {
|
||||
return hasErrorCode(err, cannotOpenFileAttachment)
|
||||
}
|
||||
|
||||
@ -255,13 +255,27 @@ func (suite *GraphErrorsUnitSuite) TestIsErrUserNotFound() {
|
||||
{
|
||||
name: "resource not found oDataErr",
|
||||
err: func() error {
|
||||
res := odErr(string(ResourceNotFound))
|
||||
res.GetError().SetMessage(ptr.To("User not found"))
|
||||
|
||||
res := odErrMsg(string(ResourceNotFound), "User not found")
|
||||
return res
|
||||
}(),
|
||||
expect: assert.True,
|
||||
},
|
||||
{
|
||||
name: "resource not found oDataErr wrapped",
|
||||
err: func() error {
|
||||
res := odErrMsg(string(ResourceNotFound), "User not found")
|
||||
return clues.Wrap(res, "getting mail folder")
|
||||
}(),
|
||||
expect: assert.True,
|
||||
},
|
||||
{
|
||||
name: "resource not found oDataErr stacked",
|
||||
err: func() error {
|
||||
res := odErrMsg(string(ResourceNotFound), "User not found")
|
||||
return clues.Stack(res, assert.AnError)
|
||||
}(),
|
||||
expect: assert.True,
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.Run(test.name, func() {
|
||||
|
||||
@ -90,10 +90,6 @@ func UserHasMailbox(ctx context.Context, acct account.Account, userID string) (b
|
||||
return false, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
||||
}
|
||||
|
||||
if graph.IsErrExchangeMailFolderNotFound(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return false, clues.Stack(err)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user