From a8102b8c42a676f5ad1ea304e16e484c824f4d19 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Mon, 1 Aug 2016 14:28:52 +0530 Subject: [PATCH] fixing VERIFONEEMMPROF-26 --- .../exception/GlobalThrowableMapper.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java index f324a2d0f..5d1ae59a7 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java @@ -57,11 +57,6 @@ public class GlobalThrowableMapper implements ExceptionMapper { if (e instanceof NotFoundException) { return ((NotFoundException) e).getResponse(); } - if (e instanceof ConstraintViolationException) { - log.error("Constraint violation", e); - return Response.status(Response.Status.BAD_REQUEST).header("Content-Type", "application/json") - .entity(400l).build(); - } if (e instanceof UnexpectedServerErrorException) { log.error("Unexpected server error", e); return ((UnexpectedServerErrorException) e).getResponse(); @@ -70,9 +65,15 @@ public class GlobalThrowableMapper implements ExceptionMapper { return ((ParameterValidationException) e).getResponse(); } if (e instanceof IllegalArgumentException) { - log.error("Illegal exception.", e); - return Response.status(Response.Status.BAD_REQUEST).header("Content-Type", "application/json") - .entity(400l).build(); + ErrorDTO errorDetail = new ErrorDTO(); + errorDetail.setCode((long) 400); + errorDetail.setMoreInfo(""); + errorDetail.setMessage(""); + errorDetail.setDescription(e.getMessage()); + return Response + .status(Response.Status.BAD_REQUEST) + .entity(errorDetail) + .build(); } if (e instanceof ClientErrorException) { log.error("Client error", e);