diff --git a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementDAOImpl.java b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementDAOImpl.java index e04a8a301180..497f6717a9eb 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementDAOImpl.java @@ -83,9 +83,7 @@ public UserDefinedLocalAuthenticatorConfig addUserDefinedLocalAuthenticator( IdentityTenantUtil.getTenantDomain(tenantId))); } IdentityDatabaseUtil.rollbackTransaction(dbConnection); - - ErrorMessages error = ErrorMessages.ERROR_WHILE_ADDING_AUTHENTICATOR; - throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e); + throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_ADDING_AUTHENTICATOR, e); } finally { IdentityDatabaseUtil.closeConnection(dbConnection); } @@ -127,8 +125,7 @@ public UserDefinedLocalAuthenticatorConfig updateUserDefinedLocalAuthenticator( existingAuthenticatorConfig.getName(), IdentityTenantUtil.getTenantDomain(tenantId))); } IdentityDatabaseUtil.rollbackTransaction(dbConnection); - ErrorMessages error = ErrorMessages.ERROR_WHILE_UPDATING_AUTHENTICATOR; - throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e); + throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_UPDATING_AUTHENTICATOR, e); } finally { IdentityDatabaseUtil.closeConnection(dbConnection); } @@ -175,8 +172,7 @@ public List getAllUserDefinedLocalAuthentic LOG.debug(String.format("Error while retrieving the all user defined local authenticators in tenant " + "domain: %s.", IdentityTenantUtil.getTenantDomain(tenantId))); } - ErrorMessages error = ErrorMessages.ERROR_WHILE_DELETING_AUTHENTICATOR; - throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e); + throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_DELETING_AUTHENTICATOR, e); } } @@ -199,8 +195,7 @@ public void deleteUserDefinedLocalAuthenticator(String authenticatorConfigName, IdentityTenantUtil.getTenantDomain(tenantId))); } IdentityDatabaseUtil.rollbackTransaction(dbConnection); - ErrorMessages error = ErrorMessages.ERROR_WHILE_DELETING_AUTHENTICATOR; - throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e); + throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_DELETING_AUTHENTICATOR, e); } finally { IdentityDatabaseUtil.closeConnection(dbConnection); } @@ -251,8 +246,7 @@ private UserDefinedLocalAuthenticatorConfig getUserDefinedLocalAuthenticatorByNa IdentityDatabaseUtil.commitTransaction(dbConnection); return config; } catch (SQLException e) { - ErrorMessages error = ErrorMessages.ERROR_WHILE_RETRIEVING_AUTHENTICATOR_BY_NAME; - throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e); + throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_RETRIEVING_AUTHENTICATOR_BY_NAME, e); } } @@ -286,7 +280,7 @@ private int getAuthenticatorIdentifier(Connection dbConnection, String authentic } IdentityDatabaseUtil.commitTransaction(dbConnection); } - throw new AuthenticatorMgtServerException(String.format("Authenticator with name: %s not found in the database." + throw buildServerException(String.format("Authenticator with name: %s not found in the database." , authenticatorConfigName)); }