Class ClientRequestException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.sdase.commons.client.jersey.error.ClientRequestException
All Implemented Interfaces:
Closeable, Serializable, AutoCloseable

public class ClientRequestException extends RuntimeException implements Closeable
Exception that wraps any WebApplicationException that occurred in a Http request to avoid that it is used to delegate the same response to the own caller by default exception mappers.
See Also:
  • Constructor Details

    • ClientRequestException

      public ClientRequestException(Throwable cause)
      Parameters:
      cause - the caught WebApplicationException that occurred in a Http request
  • Method Details

    • isClientError

      public boolean isClientError()
      Returns:
      if the response returned with a 4xx client error status code
    • isServerError

      public boolean isServerError()
      Returns:
      if the response returned with a 5xx server error status code
    • isConnectTimeout

      public boolean isConnectTimeout()
      Returns:
      if the request timed out while establishing a connection
    • isReadTimeout

      public boolean isReadTimeout()
      Returns:
      if the request timed out while reading from an established connection
    • isTimeout

      public boolean isTimeout()
      Returns:
      if the request timed out while establishing a connection or while reading from an established connection
    • isProcessingError

      public boolean isProcessingError()
      Returns:
      if the request processing failed. This error usually occurs if the response body could not be converted to the desired response entity
    • getResponse

      public Optional<jakarta.ws.rs.core.Response> getResponse()
      Returns:
      the Response of the outgoing request if available, otherwise an empty Optional
    • getWebApplicationExceptionCause

      public Optional<jakarta.ws.rs.WebApplicationException> getWebApplicationExceptionCause()
      Returns:
      the Throwable.getCause() if it is a WebApplicationException, otherwise an empty Optional
    • close

      public void close()
      This implementation can be called multiple times and will never throw an exception.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable