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

Fix Guide Rest Client Reactive Exception Handling #25714

Merged
merged 1 commit into from
May 22, 2022
Merged

Fix Guide Rest Client Reactive Exception Handling #25714

merged 1 commit into from
May 22, 2022

Conversation

felipewind
Copy link
Contributor

I believe that:

  • The implementation of ResponseExceptionMapper should be done by a class and not an interface.
  • The method toThrowable should be public, or I receive this error: Cannot reduce the visibility of the inherited method from ResponseExceptionMapper<RuntimeException>

Current version

public interface MyResponseExceptionMapper implements ResponseExceptionMapper<RuntimeException> {

    RuntimeException toThrowable(Response response) {
        if (response.getStatus() == 500) {
            throw new RuntimeException("The remote service responded with HTTP 500");
        }
        return null;
    }
}

Proposed version

public class MyResponseExceptionMapper implements ResponseExceptionMapper<RuntimeException> {

    @Override
    public RuntimeException toThrowable(Response response) {
        if (response.getStatus() == 500) {
            throw new RuntimeException("The remote service responded with HTTP 500");
        }
        return null;
    }
}

@gastaldi
Copy link
Contributor

gastaldi commented May 22, 2022

@felipewind I think we're missing a default keyword in the interface method declaration?

Ah no, you're right, the doc states that an interface is implementing another interface, which is wrong (it should have been extends) but I'll let @michalszynkiewicz and @geoand review this ;)

Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@geoand geoand merged commit 20a7686 into quarkusio:main May 22, 2022
@quarkus-bot quarkus-bot bot added this to the 2.10 - main milestone May 22, 2022
@gsmet gsmet modified the milestones: 2.10 - main, 2.9.2.Final May 24, 2022
@gsmet gsmet modified the milestones: 2.9.2.Final, 2.7.6.Final May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants