From 8a5afc0dad68b57ecf39810372ed308bbb25580b Mon Sep 17 00:00:00 2001 From: den-rgb Date: Tue, 28 Nov 2023 15:55:53 +0000 Subject: [PATCH] OCM-3963 | feat: Additional error --- pkg/aws/errors/errors.go | 5 +++++ pkg/aws/errors/errors_test.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/pkg/aws/errors/errors.go b/pkg/aws/errors/errors.go index c665eda..7349b57 100644 --- a/pkg/aws/errors/errors.go +++ b/pkg/aws/errors/errors.go @@ -75,3 +75,8 @@ func IsInvalidTokenException(err error) bool { return IsErrorCode(err, InvalidClientTokenID) } +func IsDeleteConfictException(err error) bool { + var deleteConflict *iamtypes.DeleteConflictException + return errors.As(err, &deleteConflict) +} + diff --git a/pkg/aws/errors/errors_test.go b/pkg/aws/errors/errors_test.go index 0ddc080..4fbcdf3 100644 --- a/pkg/aws/errors/errors_test.go +++ b/pkg/aws/errors/errors_test.go @@ -65,4 +65,10 @@ var _ = Describe("Error Checks", func() { Expect(IsErrorCode(err, "DifferentCode")).To(BeFalse()) }) + It("should identify IsDeleteConfictException", func() { + err := &iamtypes.DeleteConflictException{} + Expect(IsDeleteConfictException(err)).To(BeTrue()) + Expect(IsDeleteConfictException(errors.New("random error"))).To(BeFalse()) + }) + })