Skip to content

Commit

Permalink
Patched src/main/java/io/shiftleft/controller/AppErrorController.java
Browse files Browse the repository at this point in the history
  • Loading branch information
patched.codes[bot] committed May 7, 2024
1 parent 18a18e3 commit c596f89
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/io/shiftleft/controller/AppErrorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.ServletRequestAttributes;
Expand Down Expand Up @@ -38,19 +39,17 @@ public AppErrorController(ErrorAttributes errorAttributes) {
/**
* Supports the HTML Error View
* @param request
* @return
*/
@RequestMapping(value = ERROR_PATH, produces = "text/html")
@RequestMapping(value = ERROR_PATH, method = RequestMethod.GET, produces = "text/html")
public ModelAndView errorHtml(HttpServletRequest request) {
return new ModelAndView("/errors/error", getErrorAttributes(request, false));
}

/**
* Supports other formats like JSON, XML
* @param request
* @return
*/
@RequestMapping(value = ERROR_PATH)
@RequestMapping(value = ERROR_PATH, method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
Map<String, Object> body = getErrorAttributes(request, getTraceParameter(request));
Expand Down Expand Up @@ -78,7 +77,7 @@ private boolean getTraceParameter(HttpServletRequest request) {
}

private Map<String, Object> getErrorAttributes(HttpServletRequest request,
boolean includeStackTrace) {
boolean includeStackTrace) {
RequestAttributes requestAttributes = new ServletRequestAttributes(request);

Map<String,Object> m = this.errorAttributes.getErrorAttributes(requestAttributes, includeStackTrace);
Expand All @@ -102,4 +101,4 @@ private HttpStatus getStatus(HttpServletRequest request) {
}
return HttpStatus.INTERNAL_SERVER_ERROR;
}
}
}

0 comments on commit c596f89

Please sign in to comment.