Class JerseyExceptionHandling

java.lang.Object
ru.vyarus.dropwizard.guice.test.client.builder.util.JerseyExceptionHandling

public final class JerseyExceptionHandling extends Object
Jersey provides additional exception handling for shortcut executions with response type (like Invocation.Builder#method("GET", SomeClass.class)). But it is impossible to re-use this logic when Response is obtained.

This class contain a copy of exceptions logic from JerseyInvocation.translate(org.glassfish.jersey.client.ClientResponse, org.glassfish.jersey.process.internal.RequestScope, Class).

Since:
19.09.2025
  • Method Details

    • throwIfNotSuccess

      public static void throwIfNotSuccess(jakarta.ws.rs.core.Response response) throws jakarta.ws.rs.ProcessingException
      Throw custom exception for not successful response (not 2xx). The exception would be the same as with direct value call like Invocation.Builder#method("GET", SomeClass.class).
      Parameters:
      response - response to check and theow exceptions.
      Throws:
      jakarta.ws.rs.ProcessingException - for not successful request
    • convertToException

      public static jakarta.ws.rs.ProcessingException convertToException(jakarta.ws.rs.core.Response response)
      Convert response to the exception. Assumed failed response object.
      Parameters:
      response - response
      Returns:
      specialized exception (according to response status)