summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop
diff options
context:
space:
mode:
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);
}
-
}