Class ClientRequestException

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Serializable, java.lang.AutoCloseable

    public class ClientRequestException
    extends java.lang.RuntimeException
    implements java.io.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:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ClientRequestException​(java.lang.Throwable cause)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      This implementation can be called multiple times and will never throw an exception.
      java.util.Optional<javax.ws.rs.core.Response> getResponse()  
      java.util.Optional<javax.ws.rs.WebApplicationException> getWebApplicationExceptionCause()  
      boolean isClientError()  
      boolean isConnectTimeout()  
      boolean isProcessingError()  
      boolean isReadTimeout()  
      boolean isServerError()  
      boolean isTimeout()  
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ClientRequestException

        public ClientRequestException​(java.lang.Throwable cause)
        Parameters:
        cause - the caught WebApplicationException that occurred in a Http request
    • Method Detail

      • 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 java.util.Optional<javax.ws.rs.core.Response> getResponse()
        Returns:
        the Response of the outgoing request if available, otherwise an empty Optional
      • getWebApplicationExceptionCause

        public java.util.Optional<javax.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 java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable