public final class Failure extends Object implements org.joda.beans.ImmutableBean, Serializable
If calculation of a result fails this class provides details of the failure.
There is a single reason and message and a set of detailed failure items.
Each FailureItem has details of the actual cause.
In most cases, instances of Failure should be created using one of the
failure methods on Result.
| Modifier and Type | Class and Description |
|---|---|
static class |
Failure.Meta
The meta-bean for
Failure. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
FailureItem |
getFirstItem()
Gets the first failure item.
|
ImmutableSet<FailureItem> |
getItems()
Gets the set of failure items.
|
String |
getMessage()
Gets the error message associated with the failure.
|
FailureReason |
getReason()
Gets the reason associated with the failure.
|
int |
hashCode() |
static Failure.Meta |
meta()
The meta-bean for
Failure. |
Failure.Meta |
metaBean() |
static Failure |
of(Collection<FailureItem> items)
Obtains a failure for a non-empty collection of failure items.
|
static Failure |
of(FailureItem item)
Obtains a failure for a single failure item.
|
static Failure |
of(FailureItem item,
FailureItem... additionalItems)
Obtains a failure for multiple failure items.
|
static Failure |
of(FailureReason reason,
Exception cause)
Obtains a failure from a reason and exception.
|
static Failure |
of(FailureReason reason,
Exception cause,
String message,
Object... messageArgs)
Obtains a failure from a reason, message and exception.
|
static Failure |
of(FailureReason reason,
String message,
Object... messageArgs)
Obtains a failure from a reason and message.
|
static Failure |
of(FailureReason reason,
Throwable cause)
Obtains a failure from a reason and throwable.
|
static Failure |
of(FailureReason reason,
Throwable cause,
String message,
Object... messageArgs)
Obtains a failure from a reason, message and throwable.
|
String |
toString() |
public static Failure of(FailureReason reason, 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.format(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 Failure 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.format(String, Object...) for more details.
reason - the reasoncause - the causemessage - the failure message, possibly containing placeholders, formatted using Messages.format(java.lang.String, java.lang.Object)messageArgs - arguments used to create the failure messagepublic static Failure of(FailureReason reason, Exception 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.format(String, Object...) for more details.
reason - the reasoncause - the causemessage - the failure message, possibly containing placeholders, formatted using Messages.format(java.lang.String, java.lang.Object)messageArgs - arguments used to create the failure messagepublic static Failure of(FailureReason reason, Throwable cause)
reason - the reasoncause - the causepublic static Failure of(FailureReason reason, Exception cause)
reason - the reasoncause - the causepublic static Failure of(FailureItem item)
item - the failure itempublic static Failure of(FailureItem item, FailureItem... additionalItems)
item - the first failure itemadditionalItems - additional failure itemspublic static Failure of(Collection<FailureItem> items)
items - the failures, not emptypublic FailureItem getFirstItem()
There will be at least one failure item, so this always succeeds.
public static Failure.Meta meta()
Failure.public Failure.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic FailureReason getReason()
public String getMessage()
public ImmutableSet<FailureItem> getItems()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.