Skip to content

Commit

Permalink
fix: remove policy name as a param for policy already exists exception
Browse files Browse the repository at this point in the history
  • Loading branch information
roaminggypsy committed Jan 14, 2025
1 parent 90a2e1f commit 904026e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,8 @@ class PolicyNotFoundForProtectedResourceException(name: String, cause: Throwable
cause,
)

class PolicyAlreadyExistsException(name: String, cause: Throwable? = null) :
ServiceException(
Errors.Reason.POLICY_ALREADY_EXISTS,
"Policy $name already exists",
mapOf(Errors.Metadata.POLICY to name),
cause,
)
class PolicyAlreadyExistsException(cause: Throwable? = null) :
ServiceException(Errors.Reason.POLICY_ALREADY_EXISTS, "Policy already exists", emptyMap(), cause)

class PolicyBindingMembershipAlreadyExistsException(
policyName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ class PoliciesService(private val internalPoliciesStub: InternalPoliciesCoroutin
PrincipalTypeNotSupportedException(Principal.IdentityCase.TLS_CLIENT, e)
.asStatusRuntimeException(Status.Code.INVALID_ARGUMENT)
InternalErrors.Reason.POLICY_ALREADY_EXISTS ->
PolicyAlreadyExistsException(request.policy.name, e)
.asStatusRuntimeException(Status.Code.ALREADY_EXISTS)
PolicyAlreadyExistsException(e).asStatusRuntimeException(Status.Code.ALREADY_EXISTS)
InternalErrors.Reason.ROLE_NOT_FOUND ->
RoleNotFoundException.fromInternal(e).asStatusRuntimeException(e.status.code)
InternalErrors.Reason.PRINCIPAL_NOT_FOUND ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ class PoliciesServiceTest {
errorInfo {
domain = Errors.DOMAIN
reason = Errors.Reason.POLICY_ALREADY_EXISTS.name
metadata[Errors.Metadata.POLICY.key] = request.policy.name
}
)
}
Expand Down

0 comments on commit 904026e

Please sign in to comment.