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); }