public final class FailureItem extends Object implements org.joda.beans.ImmutableBean, Serializable
This is used in Failure and FailureItems to capture details of a single failure.
Details include the reason, message and stack trace.
| Modifier and Type | Class and Description |
|---|---|
static class |
FailureItem.Meta
The meta-bean for
FailureItem. |
| Modifier and Type | Field and Description |
|---|---|
static String |
EXCEPTION_MESSAGE_ATTRIBUTE
Attribute used to store the exception message.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
ImmutableMap<String,String> |
getAttributes()
Gets the attributes associated with this failure.
|
Optional<Class<? extends Throwable>> |
getCauseType()
Gets the type of the throwable that caused the failure, not present if it wasn't caused by a throwable.
|
String |
getMessage()
Gets the error message associated with the failure.
|
FailureReason |
getReason()
Gets the reason associated with the failure.
|
String |
getStackTrace()
Gets stack trace where the failure occurred.
|
int |
hashCode() |
static FailureItem.Meta |
meta()
The meta-bean for
FailureItem. |
FailureItem.Meta |
metaBean() |
static FailureItem |
of(FailureReason reason,
String message,
Object... messageArgs)
Obtains a failure from a reason and message.
|
static FailureItem |
of(FailureReason reason,
Throwable cause)
Obtains a failure from a reason and exception.
|
static FailureItem |
of(FailureReason reason,
Throwable cause,
String message,
Object... messageArgs)
Obtains a failure from a reason, throwable and message.
|
String |
toString()
Returns a string summary of the failure, as a single line excluding the stack trace.
|
FailureItem |
withAttribute(String key,
String value)
Returns an instance with the specified attribute added.
|
FailureItem |
withAttributes(Map<String,String> attributes)
Returns an instance with the specified attributes added.
|
public static final String EXCEPTION_MESSAGE_ATTRIBUTE
public static FailureItem of(FailureReason reason, String message, Object... messageArgs)
The message is produced using a template that contains zero to many "{}" or "{abc}" placeholders.
Each placeholder is replaced by the next available argument.
If the placeholder has a name, its value is added to the attributes map with the name as a key.
If there are too few arguments, then the message will be left with placeholders.
If there are too many arguments, then the excess arguments are appended to the
end of the message. No attempt is made to format the arguments.
See Messages.formatWithAttributes(String, Object...) for more details.
An exception will be created internally to obtain a stack trace. The cause type will not be present in the resulting failure.
reason - the reasonmessage - a message explaining the failure, not empty, uses "{}" for inserting messageArgsmessageArgs - the arguments for the messagepublic static FailureItem of(FailureReason reason, Throwable cause)
reason - the reasoncause - the causepublic static FailureItem of(FailureReason reason, Throwable cause, String message, Object... messageArgs)
The message is produced using a template that contains zero to many "{}" placeholders.
Each placeholder is replaced by the next available argument.
If there are too few arguments, then the message will be left with placeholders.
If there are too many arguments, then the excess arguments are appended to the
end of the message. No attempt is made to format the arguments.
See Messages.formatWithAttributes(String, Object...) for more details.
reason - the reasoncause - the causemessage - a message explaining the failure, not empty, uses "{}" for inserting messageArgsmessageArgs - the arguments for the messagepublic FailureItem withAttribute(String key, String value)
If the attribute map of this instance has the specified key, the value is replaced.
key - the key to addvalue - the value to addpublic FailureItem withAttributes(Map<String,String> attributes)
If the attribute map of this instance has any of the new attribute keys, the values are replaced.
attributes - the new attributes to addpublic String toString()
public static FailureItem.Meta meta()
FailureItem.public FailureItem.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic FailureReason getReason()
public String getMessage()
public ImmutableMap<String,String> getAttributes()
public String getStackTrace()
Exception its stack trace is used, otherwise it's the
location where the failure was created.public Optional<Class<? extends Throwable>> getCauseType()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.