From 4e96cccb95a0c07c297c75f73a268957e6c7772a Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Wed, 18 Dec 2024 14:53:27 +0530 Subject: [PATCH] Fix not logging errors from API server. --- .../v1/core/ServerAuthenticatorManagementService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/core/ServerAuthenticatorManagementService.java b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/core/ServerAuthenticatorManagementService.java index 8fcdcee760..7efca7bbb5 100644 --- a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/core/ServerAuthenticatorManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/core/ServerAuthenticatorManagementService.java @@ -1010,13 +1010,15 @@ private APIError handleIdPException(IdentityProviderManagementException e, */ private APIError handleAuthenticatorException(AuthenticatorMgtException e) { - ErrorResponse errorResponse = new ErrorResponse.Builder() + ErrorResponse.Builder errorResponseBuilder = new ErrorResponse.Builder() .withCode(e.getErrorCode()) .withMessage(e.getMessage()) - .withDescription(e.getDescription()).build(); + .withDescription(e.getDescription()); Response.Status status; + ErrorResponse errorResponse; if (e instanceof AuthenticatorMgtClientException) { + errorResponse = errorResponseBuilder.build(log, e.getMessage()); if (e.getErrorCode() != null) { String errorCode = e.getErrorCode(); errorCode = @@ -1027,6 +1029,7 @@ private APIError handleAuthenticatorException(AuthenticatorMgtException e) { errorResponse.setDescription(e.getDescription()); status = Response.Status.BAD_REQUEST; } else if (e instanceof AuthenticatorMgtServerException) { + errorResponse = errorResponseBuilder.build(log, e, e.getMessage()); if (e.getErrorCode() != null) { String errorCode = e.getErrorCode(); errorCode = @@ -1037,6 +1040,7 @@ private APIError handleAuthenticatorException(AuthenticatorMgtException e) { errorResponse.setDescription(e.getDescription()); status = Response.Status.INTERNAL_SERVER_ERROR; } else { + errorResponse = errorResponseBuilder.build(log, e, e.getMessage()); status = Response.Status.INTERNAL_SERVER_ERROR; } return new APIError(status, errorResponse);