From 4336fdf64f12a18d13650660dab3364c09f844ca Mon Sep 17 00:00:00 2001 From: hongwei Date: Tue, 3 Jun 2025 09:48:09 +0200 Subject: [PATCH] refactor/log error message for failed entitlement addition in ConsentUtil --- obp-api/src/main/scala/code/api/util/ConsentUtil.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/obp-api/src/main/scala/code/api/util/ConsentUtil.scala b/obp-api/src/main/scala/code/api/util/ConsentUtil.scala index d80d7b98c..39adbe5f8 100644 --- a/obp-api/src/main/scala/code/api/util/ConsentUtil.scala +++ b/obp-api/src/main/scala/code/api/util/ConsentUtil.scala @@ -305,7 +305,7 @@ object Consent extends MdcLoggable { Entitlement.entitlement.vend.addEntitlement(bankId, user.userId, entitlement.role_name) match { case Full(_) => (entitlement, "AddedOrExisted") case _ => - (entitlement, addConsentEntitlements + entitlement) + (entitlement, CannotAddEntitlement + entitlement) } case true => (entitlement, "AddedOrExisted") @@ -327,8 +327,10 @@ object Consent extends MdcLoggable { val failedToAdd: List[(Role, String)] = triedToAdd.filter(_._2 != "AddedOrExisted") failedToAdd match { case Nil => Full(user) - case _ => - Failure(CannotAddEntitlement + failedToAdd.map(i => (i._1, i._2)).mkString(", ")) + case _ => + //Here, we do not throw an exception, just log the error. + logger.error(CannotAddEntitlement + failedToAdd.map(i => (i._1, i._2)).mkString(", ")) + Full(user) } case _ => Failure(CannotGetEntitlements + user.userId)