update 优化 增加 rpc 异常拦截器

dev
疯狂的狮子Li 11 months ago
parent 08e407b7f4
commit 72d3e3caa8

@ -1,6 +1,7 @@
package org.dromara.common.dubbo.config;
import org.dromara.common.core.factory.YmlPropertySourceFactory;
import org.dromara.common.dubbo.handler.DubboExceptionHandler;
import org.dromara.common.dubbo.properties.DubboCustomProperties;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@ -23,4 +24,13 @@ public class DubboConfiguration {
public BeanFactoryPostProcessor customBeanFactoryPostProcessor() {
return new CustomBeanFactoryPostProcessor();
}
/**
*
*/
@Bean
public DubboExceptionHandler dubboExceptionHandler() {
return new DubboExceptionHandler();
}
}

@ -0,0 +1,27 @@
package org.dromara.common.dubbo.handler;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.rpc.RpcException;
import org.dromara.common.core.domain.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* Dubbo
*
* @author Lion Li
*/
@Slf4j
@RestControllerAdvice
public class DubboExceptionHandler {
/**
* UNIQUE
*/
@ExceptionHandler(RpcException.class)
public R<Void> handleDubboException(RpcException e) {
log.error("RPC异常: {}", e.getMessage());
return R.fail("RPC异常请联系管理员确认");
}
}
Loading…
Cancel
Save