Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 3.2.13 The provider is unable to throw a custom exception. #14426

Open
3 of 4 tasks
JusFree opened this issue Jul 12, 2024 · 3 comments
Open
3 of 4 tasks

[Bug] 3.2.13 The provider is unable to throw a custom exception. #14426

JusFree opened this issue Jul 12, 2024 · 3 comments
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage

Comments

@JusFree
Copy link

JusFree commented Jul 12, 2024

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues 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

@JusFree JusFree added component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage labels Jul 12, 2024
@wcy666103
Copy link
Contributor

It looks like someone is trying to solve this problem #14417

@JusFree
Copy link
Author

JusFree commented Jul 19, 2024

看起来有人正在尝试解决这个问题#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.

@wcy666103
Copy link
Contributor

看起来有人正在尝试解决这个问题#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage
Projects
Status: Todo
Development

No branches or pull requests

2 participants