Package spark
Class CustomErrorPages
java.lang.Object
spark.CustomErrorPages
Holds the custom error pages. A page can be defined as a String or a Route.
Note that this class is always used statically therefore custom error pages will
be shared between different instances of the Service class.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static void
Add a custom error page as a String(package private) static void
Add a custom error page as a Route handlerstatic boolean
existsFor
(int status) Verifies that a custom error page exists for the given status codegetDefaultFor
(int status) Returns the default error page for a given status code.static Object
Gets the custom error page for a given status code.private static CustomErrorPages
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
NOT_FOUND
- See Also:
-
INTERNAL_ERROR
- See Also:
-
customPages
-
defaultPages
-
-
Constructor Details
-
CustomErrorPages
private CustomErrorPages()
-
-
Method Details
-
existsFor
public static boolean existsFor(int status) Verifies that a custom error page exists for the given status code- Parameters:
status
-- Returns:
- true if error page exists
-
getFor
Gets the custom error page for a given status code. If the custom error page is a route, the output of its handle method is returned. If the custom error page is a String, it is returned as an Object.- Parameters:
status
-request
-response
-- Returns:
- Object representing the custom error page
-
getDefaultFor
Returns the default error page for a given status code. Guaranteed to never be null.- Parameters:
status
-- Returns:
- String representation of the default error page.
-
add
Add a custom error page as a String- Parameters:
status
-page
-
-
add
Add a custom error page as a Route handler- Parameters:
status
-route
-
-
getInstance
-