From c7b4f25ee6eb7601fd033b5f89c8345c5c083d5a Mon Sep 17 00:00:00 2001 From: Tucker Siegel <tgsiegel@terpmail.umd.edu> Date: Sun, 26 Mar 2023 17:44:27 -0400 Subject: [PATCH] handle differently --- .../umd/dawn/common/exceptions/CustomExceptionHandler.java | 3 +-- .../java/edu/umd/dawn/common/exceptions/DawnException.java | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) 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 9bf4cf5..f4188d6 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 11b4e75..9b4337e 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; -- GitLab