Package com.apple.foundationdb.util
Class LoggableException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.apple.foundationdb.util.LoggableException
- All Implemented Interfaces:
LoggableKeysAndValues<LoggableException>,Serializable
- Direct Known Subclasses:
BunchedMapException,MoreAsyncUtil.DeadlineExceededException,SynchronizedSessionLockedException
@API(UNSTABLE)
public class LoggableException
extends RuntimeException
implements LoggableKeysAndValues<LoggableException>
Exception type with support for adding keys and values to its log info. This can then
be logged in a way that better supports searching later.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionLoggableException(String msg) LoggableException(String msg, Object... keyValues) Create an exception with the given message a the sequence of key-value pairs.LoggableException(String msg, Throwable cause) protectedLoggableException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) LoggableException(Throwable cause) -
Method Summary
Modifier and TypeMethodDescriptionaddLogInfo(Object... keyValue) Add a list of key/value pairs to the log information.addLogInfo(String description, Object object) Add a key/value pair to the log information.Object[]Export the log information to a flattened array.Get the log information associated with this exception as a map.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
LoggableException
Create an exception with the given message a the sequence of key-value pairs. This will throw anIllegalArgumentExceptionifkeyValuescontains an odd number of elements.- Parameters:
msg- error messagekeyValues- list- See Also:
-
LoggableException
-
LoggableException
-
LoggableException
-
LoggableException
-
-
Method Details
-
getLogInfo
Get the log information associated with this exception as a map.- Specified by:
getLogInfoin interfaceLoggableKeysAndValues<LoggableException>- Returns:
- a single map with all log information
-
addLogInfo
Add a key/value pair to the log information. This will use the description given as the key and the object provided as the value.- Specified by:
addLogInfoin interfaceLoggableKeysAndValues<LoggableException>- Parameters:
description- description of the log info pairobject- value of the log info pair- Returns:
- this
LoggableException
-
addLogInfo
Add a list of key/value pairs to the log information. This will treat the list of items as pairs to be added with every even element being a key and every odd element being a value (associated with the even key preceding it). So, for example,["k0", "v0", "k1", "v1"]will add two pairs to the log info, one with key"k0"and value"v0"and one with key"k1"and value"v1". Note that this is the same format that is exported byexportLogInfo().- Specified by:
addLogInfoin interfaceLoggableKeysAndValues<LoggableException>- Parameters:
keyValue- flattened map of key-value pairs- Returns:
- this
LoggableException - Throws:
IllegalArgumentException- ifkeyValuehas odd length
-
exportLogInfo
Export the log information to a flattened array. This will flatten the map that would be returned bygetLogInfo()into an array where every even element is a key within the map and every odd element is the value associated with the key before it. So, for example,{"k0:"v0", "k1":"v1"}would be flattened into["k0", "v0", "k1", "v1"]. Note that this is the same format that is accepted byaddLogInfo(Object...)and byLoggableException(String, Object...).- Specified by:
exportLogInfoin interfaceLoggableKeysAndValues<LoggableException>- Returns:
- a flattened map of key-value pairs
-