mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-12 07:02:14 +08:00
加日志
This commit is contained in:
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,13 +30,16 @@ public class ZuulErrorController implements ErrorController {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(ERROR_PATH)
|
@RequestMapping(ERROR_PATH)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object error(HttpServletResponse response) {
|
public Object error(HttpServletRequest request, HttpServletResponse response) {
|
||||||
RequestContext ctx = RequestContext.getCurrentContext();
|
RequestContext ctx = RequestContext.getCurrentContext();
|
||||||
if (ctx.getResponse() == null) {
|
if (ctx.getResponse() == null) {
|
||||||
ctx.setResponse(response);
|
ctx.setResponse(response);
|
||||||
}
|
}
|
||||||
ctx.setResponseStatusCode(HttpStatus.OK.value());
|
ctx.setResponseStatusCode(HttpStatus.OK.value());
|
||||||
Throwable throwable = ctx.getThrowable();
|
Throwable throwable = ctx.getThrowable();
|
||||||
|
if (throwable == null) {
|
||||||
|
throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
|
||||||
|
}
|
||||||
log.error("请求错误,params:{}", ZuulContext.getApiParam(), throwable);
|
log.error("请求错误,params:{}", ZuulContext.getApiParam(), throwable);
|
||||||
return this.buildResult(throwable);
|
return this.buildResult(throwable);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user