Class CDORestException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CDORestAuthenticationException

public class CDORestException extends RuntimeException
Represents a safe REST problem that can be translated into an HTTP status and an RFC 9457 response body.

The status and problem code are part of the client-visible REST contract. The message is also sent to the caller and must therefore be written for clients; it must not contain stack traces, internal paths, credentials, or other implementation details. This exception is used by the REST service and may also be used by transport-neutral REST extensions that need to return a specific safe problem.

Author:
Eike Stepper
See Also:
  • Constructor Details

    • CDORestException

      public CDORestException(int status, String code, String message)
      Creates a REST problem with an HTTP status, stable machine-readable code, and client-visible message.
      Parameters:
      status - an HTTP error status from 400 through 599
      code - a non-empty machine-readable problem code containing lowercase ASCII letters, digits, or hyphens
      message - a safe explanation suitable for transmission to an HTTP caller
      Throws:
      IllegalArgumentException - if the status or code is invalid
      NullPointerException - if the code or message is null
  • Method Details

    • getStatus

      public int getStatus()
      Returns the HTTP status code associated with this problem.
      Returns:
      the HTTP status code
    • getCode

      public String getCode()
      Returns the stable machine-readable problem code.
      Returns:
      the problem code