Class HttpMethodNotAllowedException

All Implemented Interfaces:
Serializable

public final class HttpMethodNotAllowedException extends HttpClientErrorException
This exception corresponds to the HTTP 405 status code.
See Also:
  • Constructor Details

    • HttpMethodNotAllowedException

      public HttpMethodNotAllowedException(HTTP_METHOD... p_allowedMethods)
      Create a HTTP exception with the status code 405 Method Not Allowed.

      An optional list of allowed methods can be specified which can be used to set the HTTP Allow header in responses.

      Parameters:
      p_allowedMethods - An optional list of allowed methods.
    • HttpMethodNotAllowedException

      public HttpMethodNotAllowedException(EnumSet<HTTP_METHOD> p_allowedMethods)
      Create a HTTP exception with the status code 405 Method Not Allowed.

      An optional list of allowed methods can be specified which can be used to set the HTTP Allow header in responses.

      Parameters:
      p_allowedMethods - An optional list of allowed methods.
    • HttpMethodNotAllowedException

      public HttpMethodNotAllowedException(Throwable p_cause, HTTP_METHOD... p_allowedMethods)
      Create a HTTP exception with the status code 405 Method Not Allowed.

      An optional list of allowed methods can be specified which can be used to set the HTTP Allow header in responses.

      Parameters:
      p_cause - The cause that can be later retrieved by the Throwable.getCause() method.
      p_allowedMethods - An optional list of allowed methods.
    • HttpMethodNotAllowedException

      public HttpMethodNotAllowedException(Throwable p_cause, EnumSet<HTTP_METHOD> p_allowedMethods)
      Create a HTTP exception with the status code 405 Method Not Allowed.

      An optional list of allowed methods can be specified which can be used to set the HTTP Allow header in responses.

      Parameters:
      p_cause - The cause that can be later retrieved by the Throwable.getCause() method.
      p_allowedMethods - An optional list of allowed methods.
  • Method Details

    • getStatus

      public int getStatus()
      Description copied from class: HttpErrorException
      Get the HTTP status associated with this error.
      Overrides:
      getStatus in class HttpErrorException
      Returns:
      The HTTP status code 405 Method Not Allowed.
    • hasAllowedMethods

      public boolean hasAllowedMethods()
      Check if allowed methods are specified.
      Returns:
      true if allowed methods are specified, or false otherwise.
    • getAllowedMethods

      public EnumSet<HTTP_METHOD> getAllowedMethods()
      Get a copy of an enum set that contains all allowed methods.
      Returns:
      The enum set.
    • getAllowedMethodsHeaderValue

      public String getAllowedMethodsHeaderValue()
      Get the allowed methods formatted as a list suitable to be used as a value of the HTTP Allow header.
      Returns:
      The allowed methods, or null if hasAllowedMethods() is false.