X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fcontroller%2FSimpleErrorController.java;h=859c9134bf29155e40d44e88a93c68ff3af0addd;hb=226fd436a085f717d4cbf81bf1719bdaf1468414;hp=334a88cb954e7276eca0fa2ee3cf86668b896e64;hpb=f660cae7a447b60d84ef75f7c2bcbf62412d4579;p=portal%2Fric-dashboard.git diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java index 334a88cb..859c9134 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java @@ -1,6 +1,6 @@ /*- * ========================LICENSE_START================================= - * ORAN-OSC + * O-RAN-SC * %% * Copyright (C) 2019 AT&T Intellectual Property and Nokia * %% @@ -19,10 +19,13 @@ */ package org.oransc.ric.portal.dashboard.controller; +import java.lang.invoke.MethodHandles; import java.util.Map; import javax.servlet.http.HttpServletRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.boot.web.servlet.error.ErrorController; @@ -35,10 +38,12 @@ import org.springframework.web.context.request.WebRequest; import springfox.documentation.annotations.ApiIgnore; /** - * Returns JSON on error within the Spring-managed context. Does not fire for - * anything else; e.g., resource not found outside the context. If trace is - * requested via request parameter ("?trace=true") and available, adds stack - * trace information to the standard JSON error response. + * Provides an endpoint that returns JSON, which is invoked following any error + * within the Spring-managed context. This is NOT called for errors outside the + * context; e.g., resource not found. + * + * If trace is requested via request parameter ("?trace=true") and available, + * adds stack trace information to the standard JSON error response. * * Excluded from Swagger API documentation. * @@ -49,6 +54,8 @@ import springfox.documentation.annotations.ApiIgnore; @RestController public class SimpleErrorController implements ErrorController { + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private static final String ERROR_PATH = "/error"; private static final String TRACE = "trace"; private final ErrorAttributes errorAttributes; @@ -80,6 +87,7 @@ public class SimpleErrorController implements ErrorController { @RequestMapping(ERROR_PATH) public Map error(HttpServletRequest aRequest) { Map body = getErrorAttributes(aRequest, getTraceParameter(aRequest)); + logger.warn("Failed in request for {}", body.get("path")); body.put("decorated-by", SimpleErrorController.class.getName()); body.computeIfPresent(TRACE, (key, value) -> body.put(TRACE, ((String) value).split("\n\t"))); return body;