Package io.realm.mongodb
Class AppException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- io.realm.mongodb.AppException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ClientResetRequiredError
public class AppException extends RuntimeException
This class is a wrapper for all errors happening when communicating with a MongoDB Realm app. This include both exceptions and protocol errors. OnlygetErrorCode()
is guaranteed to contain a value. If the error was caused by an underlying exceptiongetErrorMessage()
isnull
andgetException()
is set, while if the error was a protocol errorgetErrorMessage()
is set andgetException()
is null.- See Also:
for a list of possible errors.
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AppException(ErrorCode errorCode, String errorMessage)
Create an error caused by an error in the protocol when communicating with the Object Server.AppException(ErrorCode errorCode, String nativeErrorType, int nativeErrorCode, String errorMessage, Throwable exception)
AppException(ErrorCode errorCode, String title, String hint)
Errors happening while trying to authenticate a user.AppException(ErrorCode errorCode, String errorMessage, Throwable exception)
Generic error happening that could happen anywhere.AppException(ErrorCode errorCode, Throwable exception)
Create an error caused by an an exception when communicating with the Object Server.AppException(String errorType, int errorCode, String errorMessage)
Creates an unknown error that could not be mapped to any known error case.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ErrorCode.Category
getCategory()
Returns theErrorCode.Category
category for this error.ErrorCode
getErrorCode()
Returns theErrorCode
identifying the type of error.int
getErrorIntValue()
Returns an integer representing this specific type of error.String
getErrorMessage()
Returns a more detailed error message about the cause of this error.String
getErrorType()
Returns a string describing the type of error it is.Throwable
getException()
Returns the underlying exception causing this error, if any.String
toString()
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
Constructor Detail
-
AppException
public AppException(ErrorCode errorCode, String errorMessage)
Create an error caused by an error in the protocol when communicating with the Object Server.- Parameters:
errorCode
- error code for this type of error.errorMessage
- detailed error message.
-
AppException
public AppException(String errorType, int errorCode, String errorMessage)
Creates an unknown error that could not be mapped to any known error case.This means that
getErrorCode()
will returnErrorCode.UNKNOWN
, butgetErrorType()
andgetErrorIntValue()
will return the underlying values which can help identify the real error.- Parameters:
errorCode
- error code for this type of error.errorMessage
- detailed error message.
-
AppException
public AppException(ErrorCode errorCode, Throwable exception)
Create an error caused by an an exception when communicating with the Object Server.- Parameters:
errorCode
- error code for this type of error.exception
- underlying exception causing this error.
-
AppException
public AppException(ErrorCode errorCode, String title, @Nullable String hint)
Errors happening while trying to authenticate a user.- Parameters:
errorCode
- error code for this type of error.title
- title for this type of error.hint
- a hint for resolving the error.
-
AppException
public AppException(ErrorCode errorCode, @Nullable String errorMessage, @Nullable Throwable exception)
Generic error happening that could happen anywhere.- Parameters:
errorCode
- error code for this type of error.errorMessage
- detailed error message.exception
- underlying exception if the error was caused by this.
-
-
Method Detail
-
getErrorCode
public ErrorCode getErrorCode()
Returns theErrorCode
identifying the type of error.If
ErrorCode.UNKNOWN
is returned, it means that the error could not be mapped to any known errors. In that casegetErrorType()
andgetErrorIntValue()
will return the underlying error information which can better identify the type of error.- Returns:
- the error code identifying the type of error.
- See Also:
ErrorCode
-
getErrorType
public String getErrorType()
Returns a string describing the type of error it is.- Returns:
-
getErrorIntValue
public int getErrorIntValue()
Returns an integer representing this specific type of error. This value is only unique within the value provided bygetErrorType()
.- Returns:
- the integer value representing this type of error.
-
getErrorMessage
@Nullable public String getErrorMessage()
Returns a more detailed error message about the cause of this error.- Returns:
- a detailed error message or
null
if one was not available.
-
getException
@Nullable public Throwable getException()
Returns the underlying exception causing this error, if any.- Returns:
- the underlying exception causing this error, or
null
if not caused by an exception.
-
getCategory
public ErrorCode.Category getCategory()
Returns theErrorCode.Category
category for this error. Errors that areErrorCode.Category.RECOVERABLE
mean that it is still possible for a givenSyncSession
to resume synchronization.ErrorCode.Category.FATAL
errors means that session has stopped and cannot be recovered.- Returns:
- the error category.
-
-