aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-controlloop
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2021-10-18 17:12:39 +0100
committerAjith Sreekumar <ajith.sreekumar@bell.ca>2021-10-19 15:43:21 +0000
commita9a5058eb33eda7d273bab5122736266980c99dc (patch)
treef7dc32772e18f8a9940145fdcf874722cf775b42 /runtime-controlloop
parentabd179dcba2161fb5591c48d554b9a6637b37572 (diff)
Refactor GlobalControllerExceptionHandler
Issue-ID: POLICY-3530 Change-Id: Ib33daf8491c1bf96460b424e8b0da228d65e571a Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-controlloop')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/GlobalControllerExceptionHandler.java14
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);
}
-
}