1.x
tanghc 5 years ago
parent b73850b293
commit 13f8686000
  1. 11
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/ZuulErrorController.java

@ -6,7 +6,6 @@ import com.gitee.sop.gatewaycommon.zuul.ZuulContext;
import com.netflix.zuul.context.RequestContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@ -35,12 +34,12 @@ public class ZuulErrorController implements ErrorController {
if (ctx.getResponse() == null) {
ctx.setResponse(response);
}
ctx.setResponseStatusCode(HttpStatus.OK.value());
Throwable throwable = ctx.getThrowable();
if (throwable == null) {
throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
}
log.error("请求错误,URL:{}, status:{}, params:{}",request.getRequestURL().toString(), response.getStatus(), ZuulContext.getApiParam(), throwable);
log.error("网关报错,URL:{}, status:{}, params:{}",
request.getRequestURL().toString()
, response.getStatus()
, ZuulContext.getApiParam()
, throwable);
return this.buildResult(throwable);
}

Loading…
Cancel
Save