public class FDBException extends java.lang.RuntimeException implements CloneableException
FDBException
sets
the message
of the underlying Java Exception
. FDB exceptions expose
a number of functions including, for example, isRetryable()
that
evaluate predicates on the internal FDB error. Most clients should use those methods
in order to implement special handling for certain errors if their application
requires it.
Errors in FDB should generally be retried if they match the isRetryable()
predicate. In addition, as with any distributed system, certain classes of errors
may fail in such a way that it is unclear whether the transaction succeeded (they
may be committed
or not). To handle these cases, clients
are generally advised to make their database operations idempotent and to place
their operations within retry loops. The FDB Java API provides some default retry loops
within the Database
interface. See the discussion within the documentation of
Database.runAsync()
for more details.
Transaction.onError()
,
Database.runAsync()
,
Serialized FormConstructor and Description |
---|
FDBException(java.lang.String message,
int code)
A general constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getCode()
Gets the code for this error.
|
boolean |
isMaybeCommitted()
Returns
true if the error indicates the transaction may have succeeded, though not in a way the system can verify. |
boolean |
isRetryable()
Returns
true if the error indicates the operations in the transactions should be retried because of transient error. |
boolean |
isRetryableNotCommitted()
Returns
true if the error indicates the transaction has not committed, though in a way that can be retried. |
boolean |
isSuccess()
Determine if this
FDBException represents a success code from the native layer. |
java.lang.Exception |
retargetClone()
Create and return a new
Exception that has a backtrace including the
calling line of code. |
public FDBException(java.lang.String message, int code)
message
- error message of this exceptioncode
- internal FDB error code of this exceptionpublic int getCode()
public boolean isSuccess()
FDBException
represents a success code from the native layer.true
if this error represents success, false
otherwisepublic java.lang.Exception retargetClone()
CloneableException
Exception
that has a backtrace including the
calling line of code.retargetClone
in interface CloneableException
Exception
.public boolean isRetryable()
true
if the error indicates the operations in the transactions should be retried because of transient error.true
if this FDBException
is retryable
public boolean isMaybeCommitted()
true
if the error indicates the transaction may have succeeded, though not in a way the system can verify.true
if this FDBException
is maybe_committed
public boolean isRetryableNotCommitted()
true
if the error indicates the transaction has not committed, though in a way that can be retried.true
if this FDBException
is retryable_not_committed