From: FrancescoFioraEst Date: Fri, 17 Nov 2023 13:05:07 +0000 (+0000) Subject: Update ExceptionHandler in ACM X-Git-Tag: 7.1.0~4 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=0fda289f861f95ef897fb1bb4c01cbeb9bed2310;p=policy%2Fclamp.git Update ExceptionHandler in ACM Issue-ID: POLICY-4890 Change-Id: I29cc3fe546b8b80e196750cf13e8d5e564eff0c4 Signed-off-by: FrancescoFioraEst --- diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java index 96d3bb2a7..94f7754ee 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021,2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; import org.onap.policy.clamp.models.acm.rest.RestUtils; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.errors.concepts.ErrorResponseInfo; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -33,35 +34,14 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; public class GlobalControllerExceptionHandler { /** - * Handle AutomationCompositionRuntimeException. + * Handle AutomationCompositionRuntimeException, PfModelRuntimeException and PfModelException. * - * @param ex AutomationCompositionRuntimeException + * @param ex Exception * @return ResponseEntity */ - @ExceptionHandler(AutomationCompositionRuntimeException.class) - public ResponseEntity handleBadRequest(AutomationCompositionRuntimeException ex) { - return RestUtils.toSimpleResponse(ex); - } - - /** - * Handle PfModelRuntimeException. - * - * @param ex PfModelRuntimeException - * @return ResponseEntity - */ - @ExceptionHandler(PfModelRuntimeException.class) - public ResponseEntity handleBadRequest(PfModelRuntimeException ex) { - return RestUtils.toSimpleResponse(ex); - } - - /** - * Handle PfModelException. - * - * @param ex PfModelException - * @return ResponseEntity - */ - @ExceptionHandler(PfModelException.class) - public ResponseEntity handleBadRequest(PfModelException ex) { + @ExceptionHandler({AutomationCompositionRuntimeException.class, PfModelRuntimeException.class, + PfModelException.class}) + public ResponseEntity handleBadRequest(ErrorResponseInfo ex) { return RestUtils.toSimpleResponse(ex); } }