From a9a5058eb33eda7d273bab5122736266980c99dc Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Mon, 18 Oct 2021 17:12:39 +0100 Subject: Refactor GlobalControllerExceptionHandler Issue-ID: POLICY-3530 Change-Id: Ib33daf8491c1bf96460b424e8b0da228d65e571a Signed-off-by: FrancescoFioraEst --- .../main/rest/GlobalControllerExceptionHandler.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'participant') diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java index 34b212305..8648c253e 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java @@ -23,11 +23,10 @@ package org.onap.policy.clamp.controlloop.participant.simulator.main.rest; import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; -import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse; -import org.springframework.http.HttpStatus; +import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.clamp.controlloop.models.rest.RestUtils; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; @RestControllerAdvice @@ -40,12 +39,7 @@ public class GlobalControllerExceptionHandler { * @return ResponseEntity */ @ExceptionHandler(ControlLoopException.class) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity handleBadRequest(ControlLoopException ex) { - - var resp = new CommissioningResponse(); - resp.setErrorDetails(ex.getErrorResponse().getErrorMessage()); - - return ResponseEntity.status(ex.getErrorResponse().getResponseCode().getStatusCode()).body(resp); + public ResponseEntity handleBadRequest(ControlLoopException ex) { + return RestUtils.toSimpleResponse(ex); } } -- cgit 1.2.3-korg