mirror of https://gitee.com/maxjhandsome/pig
代码优化
This commit is contained in:
parent
d071985eca
commit
ed5afa1a71
|
@ -20,9 +20,11 @@ import java.io.InputStream;
|
|||
@Slf4j
|
||||
@Component
|
||||
public class AuthFallbackProvider implements FallbackProvider {
|
||||
|
||||
private static final String AUTH_SERVICE_DISABLE = "授权模块不可用";
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse fallbackResponse(Throwable cause) {
|
||||
log.error("调用:{} 异常:{}", getRoute(), cause.getMessage());
|
||||
return new ClientHttpResponse() {
|
||||
@Override
|
||||
public HttpStatus getStatusCode() {
|
||||
|
@ -46,9 +48,11 @@ public class AuthFallbackProvider implements FallbackProvider {
|
|||
@Override
|
||||
public InputStream getBody() {
|
||||
if (cause != null && cause.getMessage() != null) {
|
||||
log.error("调用:{} 异常:{}", getRoute(), cause.getMessage());
|
||||
return new ByteArrayInputStream(cause.getMessage().getBytes());
|
||||
} else {
|
||||
return new ByteArrayInputStream("授权模块不可用".getBytes());
|
||||
log.error("调用:{} 异常:{}", getRoute(), AUTH_SERVICE_DISABLE);
|
||||
return new ByteArrayInputStream(AUTH_SERVICE_DISABLE.getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,11 @@ import java.io.InputStream;
|
|||
@Slf4j
|
||||
@Component
|
||||
public class UpmsFallbackProvider implements FallbackProvider {
|
||||
|
||||
private static final String UPMS_SERVICE_DISABLE = "权限管理模块不可用";
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse fallbackResponse(Throwable cause) {
|
||||
log.error("调用:{} 异常:{}", getRoute(), cause.getMessage());
|
||||
return new ClientHttpResponse() {
|
||||
@Override
|
||||
public HttpStatus getStatusCode() {
|
||||
|
@ -46,9 +48,11 @@ public class UpmsFallbackProvider implements FallbackProvider {
|
|||
@Override
|
||||
public InputStream getBody() {
|
||||
if (cause != null && cause.getMessage() != null) {
|
||||
log.error("调用:{} 异常:{}", getRoute(), cause.getMessage());
|
||||
return new ByteArrayInputStream(cause.getMessage().getBytes());
|
||||
} else {
|
||||
return new ByteArrayInputStream("权限管理模块不可用".getBytes());
|
||||
log.error("调用:{} 异常:{}", getRoute(), UPMS_SERVICE_DISABLE);
|
||||
return new ByteArrayInputStream(UPMS_SERVICE_DISABLE.getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue