diff options
author | Liam Fallon <liam.fallon@est.tech> | 2021-10-20 08:13:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-10-20 08:13:39 +0000 |
commit | 962a9d16895c9ae75230cad5c7d8a1d4e453f2ad (patch) | |
tree | 9e08e148d793bc659a4cb73a1e3c8cf4145c6242 /runtime-controlloop/src/main/java | |
parent | 673011f7a96c1cdb326f1b4641465db0de568023 (diff) | |
parent | a9a5058eb33eda7d273bab5122736266980c99dc (diff) |
Merge "Refactor GlobalControllerExceptionHandler"
Diffstat (limited to 'runtime-controlloop/src/main/java')
-rw-r--r-- | runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java index d093c677f..fd493fd89 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java @@ -22,6 +22,7 @@ package org.onap.policy.clamp.controlloop.runtime.main.web; import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.clamp.controlloop.models.rest.RestUtils; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; import org.springframework.http.ResponseEntity; @@ -39,9 +40,7 @@ public class GlobalControllerExceptionHandler { */ @ExceptionHandler(ControlLoopException.class) public ResponseEntity<SimpleResponse> handleBadRequest(ControlLoopException ex) { - var resp = new SimpleResponse(); - resp.setErrorDetails(ex.getErrorResponse().getErrorMessage()); - return ResponseEntity.status(ex.getErrorResponse().getResponseCode().getStatusCode()).body(resp); + return RestUtils.toSimpleResponse(ex); } /** @@ -52,9 +51,7 @@ public class GlobalControllerExceptionHandler { */ @ExceptionHandler(PfModelRuntimeException.class) public ResponseEntity<SimpleResponse> handleBadRequest(PfModelRuntimeException ex) { - var resp = new SimpleResponse(); - resp.setErrorDetails(ex.getErrorResponse().getErrorMessage()); - return ResponseEntity.status(ex.getErrorResponse().getResponseCode().getStatusCode()).body(resp); + return RestUtils.toSimpleResponse(ex); } /** @@ -65,9 +62,6 @@ public class GlobalControllerExceptionHandler { */ @ExceptionHandler(PfModelException.class) public ResponseEntity<SimpleResponse> handleBadRequest(PfModelException ex) { - var resp = new SimpleResponse(); - resp.setErrorDetails(ex.getErrorResponse().getErrorMessage()); - return ResponseEntity.status(ex.getErrorResponse().getResponseCode().getStatusCode()).body(resp); + return RestUtils.toSimpleResponse(ex); } - } |