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,java.io.Serializable
public class FDBException extends java.lang.RuntimeException implements CloneableException
An Error from the native layers of FoundationDB. EachFDBExceptionsets themessageof the underlying JavaException. 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 (theymay be committedor 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 theDatabaseinterface. See the discussion within the documentation ofDatabase.runAsync()for more details.- See Also:
Transaction.onError(),Database.runAsync(), Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FDBException(java.lang.String message, int code)A general constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCode()Gets the code for this error.booleanisMaybeCommitted()Returnstrueif the error indicates the transaction may have succeeded, though not in a way the system can verify.booleanisRetryable()Returnstrueif the error indicates the operations in the transactions should be retried because of transient error.booleanisRetryableNotCommitted()Returnstrueif the error indicates the transaction has not committed, though in a way that can be retried.booleanisSuccess()Determine if thisFDBExceptionrepresents a success code from the native layer.java.lang.ExceptionretargetClone()Create and return a newExceptionthat has a backtrace including the calling line of code.
-
-
-
Method Detail
-
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 thisFDBExceptionrepresents a success code from the native layer.- Returns:
trueif this error represents success,falseotherwise
-
retargetClone
public java.lang.Exception retargetClone()
Description copied from interface:CloneableExceptionCreate and return a newExceptionthat has a backtrace including the calling line of code.- Specified by:
retargetClonein interfaceCloneableException- Returns:
- a newly created
Exception.
-
isRetryable
public boolean isRetryable()
Returnstrueif the error indicates the operations in the transactions should be retried because of transient error.- Returns:
trueif thisFDBExceptionisretryable
-
isMaybeCommitted
public boolean isMaybeCommitted()
Returnstrueif the error indicates the transaction may have succeeded, though not in a way the system can verify.- Returns:
trueif thisFDBExceptionismaybe_committed
-
isRetryableNotCommitted
public boolean isRetryableNotCommitted()
Returnstrueif the error indicates the transaction has not committed, though in a way that can be retried.- Returns:
trueif thisFDBExceptionisretryable_not_committed
-
-