public class HandlerException extends Object implements HandleableException
Constructor and Description |
---|
HandlerException() |
HandlerException(boolean mute) |
HandlerException(Class<? extends RuntimeException> defaultException,
String message)
Build a new handler exception where default Runtime exception is
defaultException . |
HandlerException(Class<? extends RuntimeException> defaultException,
String message,
boolean mute) |
HandlerException(String message)
Build a new handler exception where default Runtime exception is
RuntimeException . |
Modifier and Type | Method and Description |
---|---|
HandleableException |
config(Class<? extends Exception> caught,
Class<? extends RuntimeException> translateTo,
String message)
Mapping
root checked exception to translateTo unchecked. |
HandleableException |
config(Class<? extends Exception> caught,
String message)
Mapping
root checked exception to unchecked, RuntimeException . |
Class<? extends RuntimeException> |
getDefaultException() |
void |
handle(Exception caught) |
void |
handle(Exception caught,
String customMessage) |
boolean |
isMute() |
boolean |
isMute(Class<? extends Exception> clazz) |
HandleableException |
logInfoOff() |
HandleableException |
logInfoOn() |
HandleableException |
mute() |
HandleableException |
mute(Class<? extends Exception> clazz) |
void |
throwMessage(String message,
Object... args)
Throw a Default Exception with a specific message using the specified formatted string and arguments.
|
public HandlerException()
public HandlerException(boolean mute)
public HandlerException(String message)
RuntimeException
.
and your default message is message
message
- default messagepublic HandlerException(Class<? extends RuntimeException> defaultException, String message)
defaultException
.
and your default message is message
defaultException
- default runtime exception when exception is catch for try / catch
block.message
- default messagepublic HandlerException(Class<? extends RuntimeException> defaultException, String message, boolean mute)
public HandleableException config(Class<? extends Exception> caught, Class<? extends RuntimeException> translateTo, String message)
HandleableException
root
checked exception to translateTo
unchecked.config
in interface HandleableException
caught
- checked exception expectedtranslateTo
- translate to another unchecked exceptionmessage
- content of exceptionpublic HandleableException config(Class<? extends Exception> caught, String message)
HandleableException
root
checked exception to unchecked, RuntimeException
.config
in interface HandleableException
caught
- checked exception expectedmessage
- content of exceptionpublic void handle(Exception caught)
handle
in interface HandleableException
public void handle(Exception caught, String customMessage)
handle
in interface HandleableException
public void throwMessage(String message, Object... args)
HandleableException
throwMessage
in interface HandleableException
message
- a format message, like: can not found method %s for class %s
args
- Arguments referenced by the format specifiers in the format string.public Class<? extends RuntimeException> getDefaultException()
getDefaultException
in interface HandleableException
public HandleableException mute()
mute
in interface HandleableException
public HandleableException mute(Class<? extends Exception> clazz)
mute
in interface HandleableException
public boolean isMute()
isMute
in interface HandleableException
public boolean isMute(Class<? extends Exception> clazz)
isMute
in interface HandleableException
public HandleableException logInfoOn()
logInfoOn
in interface HandleableException
public HandleableException logInfoOff()
logInfoOff
in interface HandleableException
Copyright © 2012–2020 jkniv, copyleft code. All rights reserved.