Package io.wcm.caravan.pipeline
Class JsonPipelineExceptionHandlers
- java.lang.Object
-
- io.wcm.caravan.pipeline.JsonPipelineExceptionHandlers
-
@ProviderType public final class JsonPipelineExceptionHandlers extends Object
Contains some common exception handling strategies to be used withJsonPipeline.handleException(JsonPipelineExceptionHandler)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JsonPipelineExceptionHandler
fallbackFor404(com.fasterxml.jackson.databind.JsonNode fallbackContent, int timeToLive)
Creates an exception handling function that will provide static fallback content if the exception being caught has a status code of 404 (and otherwise rethrow the original exception )static JsonPipelineExceptionHandler
fallbackFor50x(com.fasterxml.jackson.databind.JsonNode fallbackContent, int timeToLive)
Creates an exception handling function that will provide static fallback content if the exception being caught has a status code > 500 (and otherwise rethrow the original exception )static JsonPipelineExceptionHandler
rethrow404(RuntimeException exceptionToThrow)
Creates an exception handling function that will throw the given exception if the exception being caught has a status code of 404 (and otherwise rethrow the original exception )static JsonPipelineExceptionHandler
rethrow404(String msg)
Creates an exception handling function that will throw a newJsonPipelineInputException
with the given message if the exception being caught has a status code of 404static JsonPipelineExceptionHandler
rethrow50x(RuntimeException exceptionToThrow)
Creates an exception handling function that will throw the given exception if the exception being caught has a status code >= 500 (and otherwise rethrow the original exception )static JsonPipelineExceptionHandler
rethrow50x(String msg)
Creates an exception handling function that will throw throw a newJsonPipelineInputException
with the given message if the exception being caught has a status code in the 50x range
-
-
-
Method Detail
-
rethrow404
public static JsonPipelineExceptionHandler rethrow404(String msg)
Creates an exception handling function that will throw a newJsonPipelineInputException
with the given message if the exception being caught has a status code of 404- Parameters:
msg
- the error message- Returns:
- a function that will throw a new
JsonPipelineInputException
if status code is 404
-
rethrow404
public static JsonPipelineExceptionHandler rethrow404(RuntimeException exceptionToThrow)
Creates an exception handling function that will throw the given exception if the exception being caught has a status code of 404 (and otherwise rethrow the original exception )- Parameters:
exceptionToThrow
- the error message- Returns:
- a function that will throw a new
JsonPipelineInputException
if status code is 404
-
rethrow50x
public static JsonPipelineExceptionHandler rethrow50x(String msg)
Creates an exception handling function that will throw throw a newJsonPipelineInputException
with the given message if the exception being caught has a status code in the 50x range- Parameters:
msg
- the new error message- Returns:
- a function that will throw a new
JsonPipelineInputException
if status code is in the 50x range
-
rethrow50x
public static JsonPipelineExceptionHandler rethrow50x(RuntimeException exceptionToThrow)
Creates an exception handling function that will throw the given exception if the exception being caught has a status code >= 500 (and otherwise rethrow the original exception )- Parameters:
exceptionToThrow
- the error message- Returns:
- a function that will throw a new
JsonPipelineInputException
if status code is 404
-
fallbackFor404
public static JsonPipelineExceptionHandler fallbackFor404(com.fasterxml.jackson.databind.JsonNode fallbackContent, int timeToLive)
Creates an exception handling function that will provide static fallback content if the exception being caught has a status code of 404 (and otherwise rethrow the original exception )- Parameters:
fallbackContent
- the fallback content to returntimeToLive
- the duration in seconds for which the fallback response is allowed to be cached- Returns:
- a function that will throw a new
JsonPipelineInputException
if status code is 404
-
fallbackFor50x
public static JsonPipelineExceptionHandler fallbackFor50x(com.fasterxml.jackson.databind.JsonNode fallbackContent, int timeToLive)
Creates an exception handling function that will provide static fallback content if the exception being caught has a status code > 500 (and otherwise rethrow the original exception )- Parameters:
fallbackContent
- the fallback content to returntimeToLive
- the duration in seconds for which the fallback response is allowed to be cached- Returns:
- a function that will throw a new
JsonPipelineInputException
if status code is 404
-
-