From 61571e7b5119793bbbfb8942db5765d16fbd4fdf Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Mon, 20 Nov 2023 10:07:44 +0000 Subject: Fix missing error message in ACM Issue-ID: POLICY-4872 Change-Id: I2f7769a3bb1f6aa168f8d59ff99cb0774aee5ed7 Signed-off-by: FrancescoFioraEst --- .../clamp/acm/element/main/rest/AcElementErrorController.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'participant') diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementErrorController.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementErrorController.java index 081eb035d..770f5d8bf 100755 --- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementErrorController.java +++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementErrorController.java @@ -22,9 +22,10 @@ package org.onap.policy.clamp.acm.element.main.rest; +import static org.springframework.boot.web.error.ErrorAttributeOptions.Include; + import jakarta.servlet.RequestDispatcher; import jakarta.servlet.http.HttpServletRequest; -import java.util.Map; import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse; import org.springframework.boot.web.error.ErrorAttributeOptions; @@ -72,10 +73,14 @@ public class AcElementErrorController implements ErrorController { @SuppressWarnings("squid:S3752") @RequestMapping(value = "${server.error.path}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> handleError(HttpServletRequest request) { - Map map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request), - ErrorAttributeOptions.defaults()); + var map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request), + ErrorAttributeOptions.of(Include.MESSAGE, Include.EXCEPTION, Include.BINDING_ERRORS)); var sb = new StringBuilder(); + final var exception = map.get("exception"); + if (exception != null) { + sb.append(exception).append(" "); + } final var error = map.get("error"); if (error != null) { sb.append(error).append(" "); -- cgit 1.2.3-korg