aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-11-17 13:05:07 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2023-11-29 10:11:50 +0000
commit0fda289f861f95ef897fb1bb4c01cbeb9bed2310 (patch)
treead41aa4a956e292750e507124064febe3dda511a
parentd1f43390b090bbdb480c8da31e9fdae0c8e00be4 (diff)
Update ExceptionHandler in ACM
Issue-ID: POLICY-4890 Change-Id: I29cc3fe546b8b80e196750cf13e8d5e564eff0c4 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/GlobalControllerExceptionHandler.java34
1 files changed, 7 insertions, 27 deletions
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<SimpleResponse> handleBadRequest(AutomationCompositionRuntimeException ex) {
- return RestUtils.toSimpleResponse(ex);
- }
-
- /**
- * Handle PfModelRuntimeException.
- *
- * @param ex PfModelRuntimeException
- * @return ResponseEntity
- */
- @ExceptionHandler(PfModelRuntimeException.class)
- public ResponseEntity<SimpleResponse> handleBadRequest(PfModelRuntimeException ex) {
- return RestUtils.toSimpleResponse(ex);
- }
-
- /**
- * Handle PfModelException.
- *
- * @param ex PfModelException
- * @return ResponseEntity
- */
- @ExceptionHandler(PfModelException.class)
- public ResponseEntity<SimpleResponse> handleBadRequest(PfModelException ex) {
+ @ExceptionHandler({AutomationCompositionRuntimeException.class, PfModelRuntimeException.class,
+ PfModelException.class})
+ public ResponseEntity<SimpleResponse> handleBadRequest(ErrorResponseInfo ex) {
return RestUtils.toSimpleResponse(ex);
}
}