Class ResourceNotFoundException

All Implemented Interfaces:
Serializable

public class ResourceNotFoundException extends SlingException
An Exception that causes Sling to return a 404 (NOT FOUND) status code. This exception should not be caught but rather let be handed up the call stack up to the Sling error and exception handling.

The advantage of using this exception over the HttpServletResponse.sendError methods is that the request can be aborted immediately all the way up in the call stack and that in addition to the status code and an optional message a Throwable may be supplied providing more information.

See Also:
  • Constructor Details

    • ResourceNotFoundException

      public ResourceNotFoundException(String message)
      Creates an exception without a resource identifier.
      Parameters:
      message - The detail message
    • ResourceNotFoundException

      public ResourceNotFoundException(String resource, String message)
      Creates an exception for a missing resource.
      Parameters:
      resource - The resource identifier, or null if unspecified
      message - The detail message
    • ResourceNotFoundException

      public ResourceNotFoundException(String message, Throwable cause)
      Creates an exception with a cause and without a resource identifier.
      Parameters:
      message - The detail message
      cause - The underlying cause
    • ResourceNotFoundException

      public ResourceNotFoundException(String resource, String message, Throwable cause)
      Creates an exception for a missing resource with a cause.
      Parameters:
      resource - The resource identifier, or null if unspecified
      message - The detail message
      cause - The underlying cause
  • Method Details

    • getResource

      public String getResource()
      Returns the identifier of the missing resource.
      Returns:
      The resource identifier, or null if unspecified