diff --git a/src/main/java/edu/umd/dawn/common/exceptions/CustomExceptionHandler.java b/src/main/java/edu/umd/dawn/common/exceptions/CustomExceptionHandler.java index 9bf4cf5c3eee65fff39422a526a70bd292c7a525..f4188d60b53a51abf82895db17ddea8f773a9622 100644 --- a/src/main/java/edu/umd/dawn/common/exceptions/CustomExceptionHandler.java +++ b/src/main/java/edu/umd/dawn/common/exceptions/CustomExceptionHandler.java @@ -55,10 +55,9 @@ public class CustomExceptionHandler { @ExceptionHandler(BindException.class) protected ResponseEntity<Object> handleBindException(BindException ex, WebRequest request) { - DawnException wrapped = new DawnException(BaseExceptions.BAD_REQUEST, ex); FieldError err = ex.getFieldError(); - wrapped.setDescription("Value " + err.getRejectedValue() + " is invalid for field " + err.getField()); + DawnException wrapped = new DawnException(BaseExceptions.BAD_REQUEST, ex, "Value " + err.getRejectedValue() + " is invalid for field " + err.getField()); return returnDawnException(wrapped); } diff --git a/src/main/java/edu/umd/dawn/common/exceptions/DawnException.java b/src/main/java/edu/umd/dawn/common/exceptions/DawnException.java index 11b4e750d8b95b505f03926b097a6c67bd0d817c..9b4337e980d9cbd32fc4adc6fc684e2d4bb78e32 100644 --- a/src/main/java/edu/umd/dawn/common/exceptions/DawnException.java +++ b/src/main/java/edu/umd/dawn/common/exceptions/DawnException.java @@ -22,6 +22,12 @@ public class DawnException extends RuntimeException { base = baseException; } + public DawnException(DawnExceptionParameters parameters, Exception baseException, String description) { + this(parameters); + base = baseException; + this.description = description; + } + @Override public String getMessage() { return description;