From 48a9447ca343a578063b8dac7a4c6385f79e52f5 Mon Sep 17 00:00:00 2001 From: LakshikaAthapaththu Date: Thu, 28 Apr 2022 17:25:48 +0530 Subject: [PATCH] Re added the removed if block in throwable catch (Addressed comments) --- .../endpoint/impl/RecoverPasswordApiServiceImpl.java | 5 +++++ .../endpoint/impl/RecoverUsernameApiServiceImpl.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/RecoverPasswordApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/RecoverPasswordApiServiceImpl.java index 7461e9bc28..0e75163926 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/RecoverPasswordApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/RecoverPasswordApiServiceImpl.java @@ -94,6 +94,11 @@ public Response recoverPasswordPost(RecoveryInitiatingRequestDTO recoveryInitiat } RecoveryUtil.handleInternalServerError(Constants.SERVER_ERROR, e.getErrorCode(), LOG, e); } catch (Throwable throwable) { + if (throwable != null && StringUtils.equals(Constants.ERROR_MESSAGE_EMAIL_NOT_FOUND, + throwable.getMessage())) { + LOG.error(throwable.getMessage(), throwable); + RecoveryUtil.handleBadRequest(throwable.getMessage(), Constants.ERROR_CODE_EMAIL_NOT_FOUND); + } RecoveryUtil.handleInternalServerError(Constants.SERVER_ERROR, IdentityRecoveryConstants .ErrorMessages.ERROR_CODE_UNEXPECTED.getCode(), LOG, throwable); } diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/RecoverUsernameApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/RecoverUsernameApiServiceImpl.java index c7fa0f9631..58b799549f 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/RecoverUsernameApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/RecoverUsernameApiServiceImpl.java @@ -55,6 +55,13 @@ public Response recoverUsernamePost(List claim, String tenantDomai } RecoveryUtil.handleInternalServerError(Constants.SERVER_ERROR, e.getErrorCode(), LOG, e); } catch (Throwable throwable) { + if (throwable != null && StringUtils.equals(Constants.ERROR_MESSAGE_EMAIL_NOT_FOUND, + throwable.getMessage())) { + if (LOG.isDebugEnabled()) { + LOG.debug(throwable.getMessage()); + } + return Response.ok().build(); + } RecoveryUtil.handleInternalServerError(Constants.SERVER_ERROR, IdentityRecoveryConstants .ErrorMessages.ERROR_CODE_UNEXPECTED.getCode(), LOG, throwable); }