feign异常丢失 springboot2.3.x版本发生异常时,响应的message和exception为空问题

原因:因为boot2.3.x版本可能考虑信息安全问题,把以下两个值默认为

server:
  error:
    include-message: never
    include-exception: false

发生异常是返回

{
  "timestamp": 1632713940269,
  "status": 500,
  "error": "Internal Server Error",
  "message": "",
  "path": "/xxxx"
}

修改后

server:
  error:
    include-message: always
    include-exception: true

发生异常是返回

{
  "timestamp": 1632713940269,
  "status": 500,
  "error": "Internal Server Error",
  "exception": "com.xxxx.xxxxException",
  "message": "非法访问",
  "path": "/xxxxx"
}

 具体查看源代码:BasicErrorController.getErrorAttributeOptions

原文地址:https://www.cnblogs.com/binz/p/15342261.html