Class ResourceException

  • All Implemented Interfaces:
    java.io.Serializable

    public class ResourceException
    extends java.lang.RuntimeException
    Encapsulates a response status and the optional cause as a checked exception.

    Note that this class must implement java.io.Serializable, because it extends RuntimeException. To avoid warnings, it provides a serialVersionUID and has its non-serializable fields marked transient. The default serialization thus obtained is minimal, and may not be what the user expects.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Request request
      The request associated to this exception.
      private Response response
      The response associated to this exception.
      private static long serialVersionUID  
      private Status status
      The status associated to this exception.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Request getRequest()
      Returns the request associated to this exception.
      Response getResponse()
      Returns the response associated to this exception.
      Status getStatus()
      Returns the status associated to this exception.
      • 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
    • Field Detail

      • status

        private final transient Status status
        The status associated to this exception.
      • request

        private final transient Request request
        The request associated to this exception. Could be null.
      • response

        private final transient Response response
        The response associated to this exception. Could be null.
    • Constructor Detail

      • ResourceException

        public ResourceException​(int code)
        Constructor.
        Parameters:
        code - The specification code of the encapsulated status.
      • ResourceException

        public ResourceException​(int code,
                                 java.lang.String reasonPhrase)
        Constructor.
        Parameters:
        code - The specification code of the encapsulated status.
        reasonPhrase - The short reason phrase displayed next to the status code in a HTTP response.
      • ResourceException

        public ResourceException​(int code,
                                 java.lang.String reasonPhrase,
                                 java.lang.String description)
        Constructor.
        Parameters:
        code - The specification code of the encapsulated status.
        reasonPhrase - The short reason phrase displayed next to the status code in a HTTP response.
        description - The description of the encapsulated status.
      • ResourceException

        public ResourceException​(int code,
                                 java.lang.String name,
                                 java.lang.String description,
                                 java.lang.String uri)
        Constructor.
        Parameters:
        code - The specification code of the encapsulated status.
        name - The name of the encapsulated status.
        description - The description of the encapsulated status.
        uri - The URI of the specification describing the method.
      • ResourceException

        public ResourceException​(int code,
                                 java.lang.String reasonPhrase,
                                 java.lang.String description,
                                 java.lang.String uri,
                                 java.lang.Throwable cause)
        Constructor.
        Parameters:
        code - The specification code of the encapsulated status.
        reasonPhrase - The short reason phrase displayed next to the status code in a HTTP response.
        description - The description of the encapsulated status.
        uri - The URI of the specification describing the method.
        cause - The wrapped cause error or exception.
      • ResourceException

        public ResourceException​(int code,
                                 java.lang.Throwable cause)
        Constructor.
        Parameters:
        code - The specification code of the encapsulated status.
        cause - The wrapped cause error or exception.
      • ResourceException

        public ResourceException​(int code,
                                 java.lang.Throwable throwable,
                                 java.lang.String reasonPhrase)
        Constructor.
        Parameters:
        code - The specification code.
        throwable - The related error or exception.
        reasonPhrase - The short reason phrase displayed next to the status code in a HTTP response.
      • ResourceException

        public ResourceException​(int code,
                                 java.lang.Throwable throwable,
                                 java.lang.String reasonPhrase,
                                 java.lang.String description)
        Constructor.
        Parameters:
        code - The specification code.
        throwable - The related error or exception.
        reasonPhrase - The short reason phrase displayed next to the status code in a HTTP response.
        description - The longer description.
      • ResourceException

        public ResourceException​(int code,
                                 java.lang.Throwable throwable,
                                 java.lang.String reasonPhrase,
                                 java.lang.String description,
                                 java.lang.String uri)
        Constructor.
        Parameters:
        code - The specification code.
        throwable - The related error or exception.
        reasonPhrase - The short reason phrase displayed next to the status code in a HTTP response.
        description - The longer description.
        uri - The URI of the specification describing the method.
      • ResourceException

        public ResourceException​(Status status)
        Constructor.
        Parameters:
        status - The status to associate.
      • ResourceException

        @Deprecated
        public ResourceException​(Status status,
                                 Resource resource)
        Deprecated.
        use constructor with status, request and response instead.
        Constructor.
        Parameters:
        status - The status to associate.
      • ResourceException

        public ResourceException​(Status status,
                                 Request request,
                                 Response response)
        Constructor.
        Parameters:
        status - The status to associate.
      • ResourceException

        public ResourceException​(Status status,
                                 java.lang.String description)
        Constructor.
        Parameters:
        status - The status to copy.
        description - The description of the encapsulated status.
      • ResourceException

        public ResourceException​(Status status,
                                 java.lang.String description,
                                 java.lang.Throwable cause)
        Constructor.
        Parameters:
        status - The status to copy.
        description - The description of the encapsulated status.
        cause - The wrapped cause error or exception.
      • ResourceException

        public ResourceException​(Status status,
                                 java.lang.Throwable cause)
        Constructor.
        Parameters:
        status - The status to associate.
        cause - The wrapped cause error or exception.
      • ResourceException

        public ResourceException​(Status status,
                                 java.lang.Throwable cause,
                                 Request request,
                                 Response response)
        Constructor.
        Parameters:
        status - The status to associate.
        cause - The wrapped cause error or exception.
      • ResourceException

        public ResourceException​(java.lang.Throwable cause)
        Constructor that set the status to Status.SERVER_ERROR_INTERNAL including the related error or exception.
        Parameters:
        cause - The wrapped cause error or exception.
    • Method Detail

      • getRequest

        public Request getRequest()
        Returns the request associated to this exception.
        Returns:
        The request associated to this exception.
      • getResponse

        public Response getResponse()
        Returns the response associated to this exception.
        Returns:
        The response associated to this exception.
      • getStatus

        public Status getStatus()
        Returns the status associated to this exception.
        Returns:
        The status associated to this exception.