Package com.apple.foundationdb
Class FDBException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.apple.foundationdb.FDBException
- All Implemented Interfaces:
CloneableException
,Serializable
An Error from the native layers of FoundationDB. Each
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getCode()
Gets the code for this error.boolean
Returnstrue
if the error indicates the transaction may have succeeded, though not in a way the system can verify.boolean
Returnstrue
if the error indicates the operations in the transactions should be retried because of transient error.boolean
Returnstrue
if the error indicates the transaction has not committed, though in a way that can be retried.boolean
Determine if thisFDBException
represents a success code from the native layer.Create and return a newException
that has a backtrace including the calling line of code.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
FDBException
A general constructor. Not for use by client code.- Parameters:
message
- error message of this exceptioncode
- internal FDB error code of this exception
-
-
Method Details
-
getCode
public int getCode()Gets the code for this error. A list of common errors codes are published elsewhere within our documentation.- Returns:
- the internal FDB error code
-
isSuccess
public boolean isSuccess()Determine if thisFDBException
represents a success code from the native layer.- Returns:
true
if this error represents success,false
otherwise
-
retargetClone
Description copied from interface:CloneableException
Create and return a newException
that has a backtrace including the calling line of code.- Specified by:
retargetClone
in interfaceCloneableException
- Returns:
- a newly created
Exception
.
-
isRetryable
public boolean isRetryable()Returnstrue
if the error indicates the operations in the transactions should be retried because of transient error.- Returns:
true
if thisFDBException
isretryable
-
isMaybeCommitted
public boolean isMaybeCommitted()Returnstrue
if the error indicates the transaction may have succeeded, though not in a way the system can verify.- Returns:
true
if thisFDBException
ismaybe_committed
-
isRetryableNotCommitted
public boolean isRetryableNotCommitted()Returnstrue
if the error indicates the transaction has not committed, though in a way that can be retried.- Returns:
true
if thisFDBException
isretryable_not_committed
-