FINERACT-1971: Enhanced error logging - Attach stacktrace

This commit is contained in:
Adam Saghy
2024-02-20 08:28:27 +01:00
committed by Arnold Gálovics
parent d06b0562f1
commit 23e00ffec9
35 changed files with 39 additions and 38 deletions
@@ -39,7 +39,7 @@ public class HttpMessageNotReadableErrorController implements ExceptionMapper<Ht
public Response toResponse(HttpMessageNotReadableException exception) { public Response toResponse(HttpMessageNotReadableException exception) {
final String globalisationMessageCode = "error.msg.invalid.json.data"; final String globalisationMessageCode = "error.msg.invalid.json.data";
final String defaultUserMessage = "The referenced JSON data is invalid, validate date format as yyyy-MM-dd or other cases like String instead of Number"; final String defaultUserMessage = "The referenced JSON data is invalid, validate date format as yyyy-MM-dd or other cases like String instead of Number";
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
@@ -46,7 +46,7 @@ public class AccessDeniedExceptionMapper implements ExceptionMapper<AccessDenied
// Status code 403 really reads as: // Status code 403 really reads as:
// "Authenticated - but not authorized": // "Authenticated - but not authorized":
final String defaultUserMessage = exception.getMessage(); final String defaultUserMessage = exception.getMessage();
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized(defaultUserMessage)) return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized(defaultUserMessage))
.type(MediaType.APPLICATION_JSON).build(); .type(MediaType.APPLICATION_JSON).build();
} }
@@ -44,7 +44,7 @@ public class BadCredentialsExceptionMapper implements ExceptionMapper<BadCredent
@Override @Override
public Response toResponse(@SuppressWarnings("unused") final BadCredentialsException exception) { public Response toResponse(@SuppressWarnings("unused") final BadCredentialsException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON) return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON)
.build(); .build();
} }
@@ -36,7 +36,7 @@ public class BusinessStepExceptionMapper implements ExceptionMapper<BusinessStep
public Response toResponse(BusinessStepException exception) { public Response toResponse(BusinessStepException exception) {
final String globalisationMessageCode = "error.msg.invalid.request.body"; final String globalisationMessageCode = "error.msg.invalid.request.body";
final String defaultUserMessage = exception.getMessage(); final String defaultUserMessage = exception.getMessage();
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.parameterError(globalisationMessageCode, defaultUserMessage, "stepName"); final ApiParameterError error = ApiParameterError.parameterError(globalisationMessageCode, defaultUserMessage, "stepName");
@@ -36,7 +36,7 @@ public class BusinessStepNotBelongsToJobExceptionMapper implements ExceptionMapp
public Response toResponse(BusinessStepNotBelongsToJobException exception) { public Response toResponse(BusinessStepNotBelongsToJobException exception) {
final String globalisationMessageCode = "error.msg.invalid.request.body"; final String globalisationMessageCode = "error.msg.invalid.request.body";
final String defaultUserMessage = "One of the provided Business Steps does not belong to the provided Job Name."; final String defaultUserMessage = "One of the provided Business Steps does not belong to the provided Job Name.";
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
@@ -43,7 +43,7 @@ public class ConcurrencyFailureExceptionMapper implements FineractExceptionMappe
@Override @Override
public Response toResponse(final ConcurrencyFailureException exception) { public Response toResponse(final ConcurrencyFailureException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
String type; String type;
String identifier; String identifier;
if (exception instanceof ObjectOptimisticLockingFailureException olex) { if (exception instanceof ObjectOptimisticLockingFailureException olex) {
@@ -40,9 +40,10 @@ public class DefaultExceptionMapper implements FineractExceptionMapper, Exceptio
} }
@Override @Override
public Response toResponse(RuntimeException runtimeException) { public Response toResponse(RuntimeException exception) {
log.warn("Exception occurred", exception);
return Response.status(SC_INTERNAL_SERVER_ERROR) return Response.status(SC_INTERNAL_SERVER_ERROR)
.entity(Map.of("Exception", ObjectUtils.defaultIfNull(runtimeException.getMessage(), "No error message available"))) .entity(Map.of("Exception", ObjectUtils.defaultIfNull(exception.getMessage(), "No error message available")))
.type(MediaType.APPLICATION_JSON).build(); .type(MediaType.APPLICATION_JSON).build();
} }
} }
@@ -46,7 +46,7 @@ public class IdempotentCommandExceptionMapper implements FineractExceptionMapper
@Override @Override
public Response toResponse(final AbstractIdempotentCommandException exception) { public Response toResponse(final AbstractIdempotentCommandException exception) {
log.warn("Processing {} request: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
Integer status = null; Integer status = null;
if (exception instanceof IdempotentCommandProcessSucceedException pse) { if (exception instanceof IdempotentCommandProcessSucceedException pse) {
Integer statusCode = pse.getStatusCode(); Integer statusCode = pse.getStatusCode();
@@ -39,7 +39,7 @@ public class InvalidInstanceTypeMethodExceptionMapper implements ExceptionMapper
@Override @Override
public Response toResponse(final InvalidInstanceTypeMethodException exception) { public Response toResponse(final InvalidInstanceTypeMethodException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
ApiGlobalErrorResponse errorResponse = ApiGlobalErrorResponse.invalidInstanceTypeMethod(exception.getMethod()); ApiGlobalErrorResponse errorResponse = ApiGlobalErrorResponse.invalidInstanceTypeMethod(exception.getMethod());
return Response.status(Status.METHOD_NOT_ALLOWED).entity(errorResponse).type(MediaType.APPLICATION_JSON).build(); return Response.status(Status.METHOD_NOT_ALLOWED).entity(errorResponse).type(MediaType.APPLICATION_JSON).build();
} }
@@ -42,7 +42,7 @@ public class InvalidJsonExceptionMapper implements ExceptionMapper<InvalidJsonEx
public Response toResponse(@SuppressWarnings("unused") final InvalidJsonException exception) { public Response toResponse(@SuppressWarnings("unused") final InvalidJsonException exception) {
final String globalisationMessageCode = "error.msg.invalid.request.body"; final String globalisationMessageCode = "error.msg.invalid.request.body";
final String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing."; final String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing.";
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
@@ -44,7 +44,7 @@ public class InvalidTenantIdentifierExceptionMapper implements ExceptionMapper<I
@Override @Override
public Response toResponse(@SuppressWarnings("unused") final InvalidTenantIdentifierException exception) { public Response toResponse(@SuppressWarnings("unused") final InvalidTenantIdentifierException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.invalidTenantIdentifier()) return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.invalidTenantIdentifier())
.type(MediaType.APPLICATION_JSON).build(); .type(MediaType.APPLICATION_JSON).build();
} }
@@ -34,7 +34,7 @@ public class JobIsNotFoundOrNotEnabledExceptionMapper implements ExceptionMapper
@Override @Override
public Response toResponse(JobIsNotFoundOrNotEnabledException exception) { public Response toResponse(JobIsNotFoundOrNotEnabledException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
return Response.status(Response.Status.FORBIDDEN) return Response.status(Response.Status.FORBIDDEN)
.entity(ApiGlobalErrorResponse.jobIsDisabled(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage())) .entity(ApiGlobalErrorResponse.jobIsDisabled(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage()))
.type(MediaType.APPLICATION_JSON).build(); .type(MediaType.APPLICATION_JSON).build();
@@ -38,7 +38,7 @@ public class JsonPathExceptionMapper implements ExceptionMapper<JsonPathExceptio
public Response toResponse(JsonPathException exception) { public Response toResponse(JsonPathException exception) {
final String globalisationMessageCode = "error.msg.invalid.json.path"; final String globalisationMessageCode = "error.msg.invalid.json.path";
final String defaultUserMessage = "The referenced JSON path is invalid."; final String defaultUserMessage = "The referenced JSON path is invalid.";
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
@@ -42,7 +42,7 @@ public class JsonSyntaxExceptionMapper implements ExceptionMapper<JsonSyntaxExce
public Response toResponse(final JsonSyntaxException exception) { public Response toResponse(final JsonSyntaxException exception) {
final String globalisationMessageCode = "error.msg.invalid.request.body"; final String globalisationMessageCode = "error.msg.invalid.request.body";
final String defaultUserMessage = "The JSON syntax provided in the body of the request is invalid: " + exception.getMessage(); final String defaultUserMessage = "The JSON syntax provided in the body of the request is invalid: " + exception.getMessage();
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
@@ -42,7 +42,7 @@ public class MalformedJsonExceptionMapper implements ExceptionMapper<MalformedJs
public Response toResponse(@SuppressWarnings("unused") final MalformedJsonException exception) { public Response toResponse(@SuppressWarnings("unused") final MalformedJsonException exception) {
final String globalisationMessageCode = "error.msg.invalid.request.body"; final String globalisationMessageCode = "error.msg.invalid.request.body";
final String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing."; final String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing.";
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
@@ -47,7 +47,7 @@ public class NoAuthorizationExceptionMapper implements ExceptionMapper<NoAuthori
// Status code 403 really reads as: // Status code 403 really reads as:
// "Authenticated - but not authorized": // "Authenticated - but not authorized":
final String defaultUserMessage = exception.getMessage(); final String defaultUserMessage = exception.getMessage();
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized(defaultUserMessage)) return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized(defaultUserMessage))
.type(MediaType.APPLICATION_JSON).build(); .type(MediaType.APPLICATION_JSON).build();
} }
@@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.ServletException; import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse; import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.AuthenticationException;
@@ -32,9 +31,9 @@ import org.springframework.security.web.AuthenticationEntryPoint;
public class OAuth2ExceptionEntryPoint implements AuthenticationEntryPoint { public class OAuth2ExceptionEntryPoint implements AuthenticationEntryPoint {
@Override @Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception)
throws IOException, ServletException { throws ServletException {
log.warn("Exception: {}, Message: {}", authException.getClass().getName(), authException.getMessage()); log.warn("Exception occurred", exception);
ApiGlobalErrorResponse errorResponse = ApiGlobalErrorResponse.unAuthenticated(); ApiGlobalErrorResponse errorResponse = ApiGlobalErrorResponse.unAuthenticated();
response.setContentType("application/json"); response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
@@ -43,7 +43,7 @@ public class OptimisticLockExceptionMapper implements FineractExceptionMapper, E
@Override @Override
public Response toResponse(final OptimisticLockException exception) { public Response toResponse(final OptimisticLockException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
String type = exception.getQuery() == null ? "unknown" : "query"; String type = exception.getQuery() == null ? "unknown" : "query";
String identifier = "unknown"; String identifier = "unknown";
final ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.conflict(type, identifier); final ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.conflict(type, identifier);
@@ -45,7 +45,7 @@ public class PlatformApiDataValidationExceptionMapper
@Override @Override
public Response toResponse(final PlatformApiDataValidationException exception) { public Response toResponse(final PlatformApiDataValidationException exception) {
log.warn("Exception: {}, Message: {}, Errors: {}", exception.getClass().getName(), exception.getMessage(), exception.getErrors()); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse dataValidationErrorResponse = ApiGlobalErrorResponse final ApiGlobalErrorResponse dataValidationErrorResponse = ApiGlobalErrorResponse
.badClientRequest(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getErrors()); .badClientRequest(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getErrors());
@@ -44,7 +44,7 @@ public class PlatformDataIntegrityExceptionMapper implements FineractExceptionMa
@Override @Override
public Response toResponse(final PlatformDataIntegrityException exception) { public Response toResponse(final PlatformDataIntegrityException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.dataIntegrityError(exception.getGlobalisationMessageCode(), final ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.dataIntegrityError(exception.getGlobalisationMessageCode(),
exception.getDefaultUserMessage(), exception.getParameterName(), exception.getDefaultUserMessageArgs()); exception.getDefaultUserMessage(), exception.getParameterName(), exception.getDefaultUserMessageArgs());
@@ -44,7 +44,7 @@ public class PlatformDomainRuleExceptionMapper implements FineractExceptionMappe
@Override @Override
public Response toResponse(final AbstractPlatformDomainRuleException exception) { public Response toResponse(final AbstractPlatformDomainRuleException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation( final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation(
exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
// request understood but not carried out due to it violating some // request understood but not carried out due to it violating some
@@ -43,7 +43,7 @@ public class PlatformInternalServerExceptionMapper implements FineractExceptionM
@Override @Override
public Response toResponse(final PlatformInternalServerException exception) { public Response toResponse(final PlatformInternalServerException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.serverSideError(exception.getGlobalisationMessageCode(), final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.serverSideError(exception.getGlobalisationMessageCode(),
exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build(); return Response.status(Status.INTERNAL_SERVER_ERROR).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build();
@@ -38,7 +38,7 @@ public class PlatformRequestBodyItemLimitValidationExceptionMapper
@Override @Override
public Response toResponse(PlatformRequestBodyItemLimitValidationException exception) { public Response toResponse(PlatformRequestBodyItemLimitValidationException exception) {
String globalisationMessage = "error.msg.validation.request.body.item.limit.validation"; String globalisationMessage = "error.msg.validation.request.body.item.limit.validation";
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse badRequestErrorResponse = ApiGlobalErrorResponse.badClientRequest(globalisationMessage, final ApiGlobalErrorResponse badRequestErrorResponse = ApiGlobalErrorResponse.badClientRequest(globalisationMessage,
exception.getMessage()); exception.getMessage());
return Response.status(Response.Status.BAD_REQUEST).entity(badRequestErrorResponse).type(MediaType.APPLICATION_JSON).build(); return Response.status(Response.Status.BAD_REQUEST).entity(badRequestErrorResponse).type(MediaType.APPLICATION_JSON).build();
@@ -45,7 +45,7 @@ public class PlatformResourceNotFoundExceptionMapper
@Override @Override
public Response toResponse(final AbstractPlatformResourceNotFoundException exception) { public Response toResponse(final AbstractPlatformResourceNotFoundException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.notFound(exception.getGlobalisationMessageCode(), final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.notFound(exception.getGlobalisationMessageCode(),
exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
return Response.status(Status.NOT_FOUND).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build(); return Response.status(Status.NOT_FOUND).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build();
@@ -45,7 +45,7 @@ public class PlatformServiceUnavailableExceptionMapper implements ExceptionMappe
@Override @Override
public Response toResponse(final AbstractPlatformServiceUnavailableException exception) { public Response toResponse(final AbstractPlatformServiceUnavailableException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse serviceUnavailableExceptionResponse = ApiGlobalErrorResponse.serviceUnavailable( final ApiGlobalErrorResponse serviceUnavailableExceptionResponse = ApiGlobalErrorResponse.serviceUnavailable(
exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
return Response.status(Status.SERVICE_UNAVAILABLE).entity(serviceUnavailableExceptionResponse).type(MediaType.APPLICATION_JSON) return Response.status(Status.SERVICE_UNAVAILABLE).entity(serviceUnavailableExceptionResponse).type(MediaType.APPLICATION_JSON)
@@ -45,7 +45,7 @@ public class RollbackTransactionNotApprovedExceptionMapper
@Override @Override
public Response toResponse(final RollbackTransactionNotApprovedException exception) { public Response toResponse(final RollbackTransactionNotApprovedException exception) {
log.warn("Exception: {}", exception.getClass().getName()); log.warn("Exception occurred", exception);
return Response.ok().entity(new Gson().toJson(exception.getResult())).type(MediaType.APPLICATION_JSON).build(); return Response.ok().entity(new Gson().toJson(exception.getResult())).type(MediaType.APPLICATION_JSON).build();
} }
@@ -42,7 +42,7 @@ public class UnAuthenticatedUserExceptionMapper implements ExceptionMapper<UnAut
@Override @Override
public Response toResponse(@SuppressWarnings("unused") final UnAuthenticatedUserException exception) { public Response toResponse(@SuppressWarnings("unused") final UnAuthenticatedUserException exception) {
// Status code 401 really reads as: "Unauthenticated": // Status code 401 really reads as: "Unauthenticated":
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON) return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON)
.build(); .build();
} }
@@ -55,7 +55,7 @@ public class UnrecognizedQueryParamExceptionMapper implements ExceptionMapper<Un
.append(parameterName) // .append(parameterName) //
.append(" has an unsupported value of: ") // .append(" has an unsupported value of: ") //
.append(parameterValue); .append(parameterValue);
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultEnglishMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
parameterName, parameterName, parameterValue, exception.getSupportedParams()); parameterName, parameterName, parameterValue, exception.getSupportedParams());
@@ -53,7 +53,7 @@ public class UnsupportedCommandExceptionMapper implements ExceptionMapper<Unsupp
if (message != null) { if (message != null) {
defaultEnglishMessage.append(" ").append(message); defaultEnglishMessage.append(" ").append(message);
} }
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultEnglishMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
exception.getUnsupportedCommandName(), exception.getUnsupportedCommandName()); exception.getUnsupportedCommandName(), exception.getUnsupportedCommandName());
@@ -55,7 +55,7 @@ public class UnsupportedParameterExceptionMapper implements FineractExceptionMap
errors.add(error); errors.add(error);
} }
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), errors); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse final ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse
.badClientRequest("validation.msg.validation.errors.exist", "Validation errors exist.", errors); .badClientRequest("validation.msg.validation.errors.exist", "Validation errors exist.", errors);
@@ -36,7 +36,7 @@ public class ExternalAssetOwnerInitiateTransferExceptionMapper implements Except
public Response toResponse(ExternalAssetOwnerInitiateTransferException exception) { public Response toResponse(ExternalAssetOwnerInitiateTransferException exception) {
final String globalisationMessageCode = "error.msg.external.asset.owner.initiate"; final String globalisationMessageCode = "error.msg.external.asset.owner.initiate";
final String defaultUserMessage = exception.getMessage(); final String defaultUserMessage = exception.getMessage();
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
@@ -35,7 +35,7 @@ public class LinkedAccountRequiredExceptionMapper implements FineractExceptionMa
@Override @Override
public Response toResponse(LinkedAccountRequiredException exception) { public Response toResponse(LinkedAccountRequiredException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation( final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation(
exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
// request understood but not carried out due to it violating some // request understood but not carried out due to it violating some
@@ -36,6 +36,7 @@ public class LoanIdsHardLockedExceptionMapper implements FineractExceptionMapper
@Override @Override
public Response toResponse(LoanIdsHardLockedException exception) { public Response toResponse(LoanIdsHardLockedException exception) {
log.warn("Exception occurred", exception);
return Response.status(HttpStatus.SC_CONFLICT) return Response.status(HttpStatus.SC_CONFLICT)
.entity(ApiGlobalErrorResponse.loanIsLocked(exception.getLoanIdFromRequest()).toJson()).type(MediaType.APPLICATION_JSON) .entity(ApiGlobalErrorResponse.loanIsLocked(exception.getLoanIdFromRequest()).toJson()).type(MediaType.APPLICATION_JSON)
.build(); .build();
@@ -36,7 +36,7 @@ public class MultiDisbursementDataRequiredExceptionMapper
@Override @Override
public Response toResponse(MultiDisbursementDataRequiredException exception) { public Response toResponse(MultiDisbursementDataRequiredException exception) {
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage()); log.warn("Exception occurred", exception);
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation( final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation(
exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
// request understood but not carried out due to it violating some // request understood but not carried out due to it violating some
@@ -36,7 +36,7 @@ public class LoanAccountLockCannotBeOverruledExceptionMapper implements Exceptio
public Response toResponse(LoanAccountLockCannotBeOverruledException exception) { public Response toResponse(LoanAccountLockCannotBeOverruledException exception) {
final String globalisationMessageCode = "error.msg.invalid.request.body"; final String globalisationMessageCode = "error.msg.invalid.request.body";
final String defaultUserMessage = exception.getMessage(); final String defaultUserMessage = exception.getMessage();
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage); log.warn("Exception occurred", exception);
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);