You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "JusFree (via GitHub)" <gi...@apache.org> on 2024/07/12 10:31:39 UTC

[I] [Bug] 3.2.13 The provider is unable to throw a custom exception. [dubbo]

JusFree opened a new issue, #14426:
URL: https://github.com/apache/dubbo/issues/14426

   ### Pre-check
   
   - [X] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   3.2.13
   
   ### Steps to reproduce this issue
   
   Declared a custom interceptor using SPI as follows:
   ```
   @Activate(group = {CommonConstants.PROVIDER})
   public class DubboExceptionFilter implements Filter {
       @Override
       public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
           try {
               Result result = invoker.invoke(invocation);
               if (result.hasException()) {
                   Throwable exception = result.getException();
                   if (exception instanceof BaseException) {
                       BaseException customException = (BaseException) exception;
                       return AsyncRpcResult.newDefaultAsyncResult(new BaseException(customException.getMessage(), customException.getCode()), invocation);
                   }
               }
               return result;
           } catch (RpcException e) {
               throw e;
           }
       }
   }
   ```
   However, the exception returned by the caller is still wrapped in a RuntimeException.
   
   ### What you expected to happen
   
   Able to correctly retrieve the custom exception.
   
   
   
   
   
   
   
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [ ] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] 3.2.13 The provider is unable to throw a custom exception. [dubbo]

Posted by "JusFree (via GitHub)" <gi...@apache.org>.
JusFree commented on issue #14426:
URL: https://github.com/apache/dubbo/issues/14426#issuecomment-2475819215

   > 请问后续有什么方案可以解决这个问题吗
   
   目前时放在api目录下,他是可以抛出自定义异常的,之前看了源码如果要不限包抛出自定义异常的话需要自己定义白名单,侵入性有点大就没有去改造了。
   路径大概如下:
   ![image](https://github.com/user-attachments/assets/392701f3-5d3a-47d4-8591-d1c2fa48bf1e)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] 3.2.13 The provider is unable to throw a custom exception. [dubbo]

Posted by "wcy666103 (via GitHub)" <gi...@apache.org>.
wcy666103 commented on issue #14426:
URL: https://github.com/apache/dubbo/issues/14426#issuecomment-2238166984

   > > 看起来有人正在尝试解决这个问题#14417
   > 
   > There are some differences. #14417 deals with cross-language exceptions, while my issue concerns custom exceptions between Java services. In the ExceptionFilter, when the same exception is defined within the same directory as the API, it can be thrown directly. However, when the API and the exception class are not in the same package, the exception is uniformly wrapped as a RuntimeException.
   
   You can submit a pr to try and fix the issue you're having.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] 3.2.13 The provider is unable to throw a custom exception. [dubbo]

Posted by "JusFree (via GitHub)" <gi...@apache.org>.
JusFree commented on issue #14426:
URL: https://github.com/apache/dubbo/issues/14426#issuecomment-2238072295

   > 看起来有人正在尝试解决这个问题#14417
   
   There are some differences. #14417 deals with cross-language exceptions, while my issue concerns custom exceptions between Java services. In the ExceptionFilter, when the same exception is defined within the same directory as the API, it can be thrown directly. However, when the API and the exception class are not in the same package, the exception is uniformly wrapped as a RuntimeException.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] 3.2.13 The provider is unable to throw a custom exception. [dubbo]

Posted by "wcy666103 (via GitHub)" <gi...@apache.org>.
wcy666103 commented on issue #14426:
URL: https://github.com/apache/dubbo/issues/14426#issuecomment-2225295055

   It looks like someone is trying to solve this problem https://github.com/apache/dubbo/pull/14417


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] 3.2.13 The provider is unable to throw a custom exception. [dubbo]

Posted by "incubus-ohy (via GitHub)" <gi...@apache.org>.
incubus-ohy commented on issue #14426:
URL: https://github.com/apache/dubbo/issues/14426#issuecomment-2475361901

   请问后续有什么方案可以解决这个问题吗


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org