因为 cloud内部抛出异常不进行处理,Feign获取spring默认包装异常结果如下:
{
"timestamp": "2017-12-27 15:01:53",
"status": 500,
"error": "Internal Server Error",
"exception": "com.keruyun.loyalty.commons.master.exception.BusinessException",
"message": "Request processing failed; nested exception is {\"code\":1000, \"message\":\"test Exception\"}",
"path": "/coupon/cloud/commercial/8469"
}
自定义的异常处理下返回状态
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandlerResolver {
//内部服务异常处理
@ExceptionHandler(InternalApiException.class)
public ResultResp<?> handleGlobalException(HttpServletResponse response, InternalApiException internalApiException) {
ResultResp<?> resultResp = internalApiException.getResultResp();
log.error(internalApiException.getMessage(), internalApiException);
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());//返回500异常
response.setContentType(MediaType.APPLICATION_JSON_UTF8.toString());
return resultResp;
}
}
每个月有2-3次帮海澜之家清库存,有没有人想要加个副业的,3天有 500-2000元+,不用投钱,不用辞职,会用手机就行。时间自由无压力!手把手教包会!有意者扫码私聊我!