NRError

open class NRError @JvmOverloads constructor(var errorCode: String = GeneralError, var reason: String? = Unknown, var description: String? = null, var data: Any? = null)

Represents a failure that can occur during a chat session.

Errors are delivered through ChatEventListener.onError. Use errorCode to determine the type of failure and the appropriate recovery action in your application.

Handling errors:

override fun onError(error: NRError) {
when (error.errorCode) {
NRError.AuthorizationRequired -> {
// Re-authenticate and call ChatController.reauthorizeImplicitFlow.
}
NRError.AttachmentValidationError -> {
// Inform the user about file size/type restrictions.
}
NRError.ClientNotAuthenticatedError, NRError.AuthLogoutError -> {
// Return the user to the login screen.
}
else -> {
// Show a generic error message.
}
}
}

Constructors

Link copied to clipboard
constructor(errorCode: String = GeneralError, reason: String? = Unknown, description: String? = null, data: Any? = null)
constructor(errorCode: String, description: String?, data: Any? = null)
constructor(error: NRError, data: Any?)
constructor(exception: Throwable)

Types

Link copied to clipboard
object Companion

Error codes and reasons used as values of errorCode and reason.

Link copied to clipboard
annotation class ErrorCode

Marks a String value as one of the error code constants defined in the companion object.

Link copied to clipboard
annotation class ErrorReason

Marks a String value as one of the error reason constants defined in the companion object.

Properties

Link copied to clipboard
var data: Any?

Optional payload attached to the error (for example, a Throwable cause).

Link copied to clipboard
@SerializedName(value = "error")
var description: String?

Optional human-readable description of the failure.

Link copied to clipboard

Code identifying the type of failure. One of the constants defined in the companion object.

Link copied to clipboard

Optional machine-readable reason that complements errorCode (for example, a transport error category or HTTP status hint).

Functions

Link copied to clipboard
fun data(data: Any? = null): NRError
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Two errors are equal when their errorCode, reason, description, and data are equal.

Link copied to clipboard
open override fun hashCode(): Int

Returns a hash code based on errorCode and reason.

Link copied to clipboard
open override fun toString(): String

Returns a description of this error containing errorCode, reason, and description.