mirror of https://gitee.com/maxjhandsome/pig
♻️ Refactoring code. #I44W82 token失效后 处理后pig-auth 项目未捕获到失效错误json提示 前台返回的还是500错误 无法获取到失效提示json 跳转登录页
This commit is contained in:
parent
4b97369107
commit
435eae5ad0
|
@ -42,6 +42,8 @@ public class PigAuth2ExceptionSerializer extends StdSerializer<PigAuth2Exception
|
|||
gen.writeObjectField("code", CommonConstants.FAIL);
|
||||
gen.writeStringField("msg", value.getMessage());
|
||||
gen.writeStringField("data", value.getErrorCode());
|
||||
// 资源服务器会读取这个字段
|
||||
gen.writeStringField("error", value.getMessage());
|
||||
gen.writeEndObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,9 +75,14 @@ public class PigResourceServerAutoConfiguration {
|
|||
@Override
|
||||
@SneakyThrows
|
||||
public void handleError(ClientHttpResponse response) {
|
||||
if (response.getRawStatusCode() != HttpStatus.BAD_REQUEST.value()) {
|
||||
super.handleError(response);
|
||||
// 当认证中心返回 400 或者 424 错误码不抛异常,交给资源服务自行处理
|
||||
if (response.getRawStatusCode() == HttpStatus.FAILED_DEPENDENCY.value()
|
||||
|| response.getRawStatusCode() == HttpStatus.BAD_REQUEST.value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 原有异常处理逻辑
|
||||
super.handleError(response);
|
||||
}
|
||||
});
|
||||
return restTemplate;
|
||||
|
|
Loading…
Reference in New Issue