|
|
|
@ -31,6 +31,7 @@ import org.springframework.http.ResponseEntity;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -81,16 +82,6 @@ public class BasicErrorController extends AbstractErrorController {
|
|
|
|
|
return this.errorProperties.getPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(produces = { "application/xml", "text/xml", "application/json",
|
|
|
|
|
"application/*+xml", "application/*+json" })
|
|
|
|
|
public ResponseEntity<Map<String, Object>> errorStructured(
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> body = getErrorAttributes(request,
|
|
|
|
|
isIncludeStackTrace(request, MediaType.ALL));
|
|
|
|
|
HttpStatus status = getStatus(request);
|
|
|
|
|
return new ResponseEntity<Map<String, Object>>(body, status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(produces = "text/html")
|
|
|
|
|
public ModelAndView errorHtml(HttpServletRequest request,
|
|
|
|
|
HttpServletResponse response) {
|
|
|
|
@ -103,20 +94,12 @@ public class BasicErrorController extends AbstractErrorController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping
|
|
|
|
|
public ResponseEntity<String> errorText(HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> attributes = getErrorAttributes(request,
|
|
|
|
|
isIncludeStackTrace(request, MediaType.TEXT_PLAIN));
|
|
|
|
|
int padding = 0;
|
|
|
|
|
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
|
|
|
|
|
padding = Math.max(padding, entry.getKey().length());
|
|
|
|
|
}
|
|
|
|
|
StringBuffer body = new StringBuffer();
|
|
|
|
|
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
|
|
|
|
|
body.append(String.format("%-" + padding + "s : %s%n", entry.getKey(),
|
|
|
|
|
entry.getValue()));
|
|
|
|
|
}
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> body = getErrorAttributes(request,
|
|
|
|
|
isIncludeStackTrace(request, MediaType.ALL));
|
|
|
|
|
HttpStatus status = getStatus(request);
|
|
|
|
|
return new ResponseEntity<String>(body.toString(), status);
|
|
|
|
|
return new ResponseEntity<Map<String, Object>>(body, status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|