public class MongoException
extends java.lang.RuntimeException
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TRANSIENT_TRANSACTION_ERROR_LABEL
An error label indicating that the exception can be treated as a transient transaction error.
|
static java.lang.String |
UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL
An error label indicating that the exception can be treated as an unknown transaction commit result.
|
Constructor and Description |
---|
MongoException(int code,
java.lang.String msg) |
MongoException(int code,
java.lang.String msg,
java.lang.Throwable t) |
MongoException(java.lang.String msg) |
MongoException(java.lang.String msg,
java.lang.Throwable t) |
Modifier and Type | Method and Description |
---|---|
void |
addLabel(java.lang.String errorLabel)
Adds the given error label to the exception.
|
static MongoException |
fromThrowable(java.lang.Throwable t)
Static helper to create or cast a MongoException from a throwable
|
static MongoException |
fromThrowableNonNull(java.lang.Throwable t)
Static helper to create or cast a MongoException from a throwable
|
int |
getCode()
Gets the exception code
|
java.util.Set<java.lang.String> |
getErrorLabels()
Gets the set of error labels associated with this exception.
|
boolean |
hasErrorLabel(java.lang.String errorLabel)
Return true if the exception is labelled with the given error label, and false otherwise.
|
void |
removeLabel(java.lang.String errorLabel)
Removes the given error label from the exception.
|
public static final java.lang.String TRANSIENT_TRANSACTION_ERROR_LABEL
hasErrorLabel(String)
,
Constant Field Valuespublic static final java.lang.String UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL
hasErrorLabel(String)
,
Constant Field Valuespublic MongoException(java.lang.String msg)
msg
- the messagepublic MongoException(int code, java.lang.String msg)
code
- the error codemsg
- the messagepublic MongoException(java.lang.String msg, java.lang.Throwable t)
msg
- the messaget
- the throwable causepublic MongoException(int code, java.lang.String msg, java.lang.Throwable t)
code
- the error codemsg
- the messaget
- the throwable cause@Nullable public static MongoException fromThrowable(@Nullable java.lang.Throwable t)
t
- a throwable, which may be nullpublic static MongoException fromThrowableNonNull(java.lang.Throwable t)
t
- a throwable, which may not be nullpublic int getCode()
public void addLabel(java.lang.String errorLabel)
errorLabel
- the non-null error label to add to the exceptionpublic void removeLabel(java.lang.String errorLabel)
errorLabel
- the non-null error label to remove from the exceptionpublic java.util.Set<java.lang.String> getErrorLabels()
public boolean hasErrorLabel(java.lang.String errorLabel)
errorLabel
- the non-null error labelCopyright © 2010 - 2020 Adobe. All Rights Reserved