Class ChatErrorKt
-
- All Implemented Interfaces:
public final class ChatErrorKt
-
-
Method Summary
Modifier and Type Method Description final static Error.NetworkErrorfromChatErrorCode(Error.NetworkError.Companion $self, ChatErrorCode chatErrorCode, Integer statusCode, Throwable cause)Creates Error.NetworkError from ChatErrorCode with custom status code and optional cause. final static BooleanisPermanent(Error $self)Returns true if an error is a permanent failure instead of a temporary one (broken network, 500, rate limit etc. final static BooleanisMessageAlreadyExists(Error $self)final static ErrorcopyWithMessage(Error $self, String message)Copies the original Error objects with custom message. final static ThrowableextractCause(Error $self)Extracts the cause from Error object or null if it's not available. -
-
Method Detail
-
fromChatErrorCode
final static Error.NetworkError fromChatErrorCode(Error.NetworkError.Companion $self, ChatErrorCode chatErrorCode, Integer statusCode, Throwable cause)
Creates Error.NetworkError from ChatErrorCode with custom status code and optional cause.
- Parameters:
chatErrorCode- The ChatErrorCode from which the error should be created.statusCode- HTTP status code or UNKNOWN_STATUS_CODE if not available.cause- The optional Throwable associated with the error.- Returns:
Error.NetworkError instance.
-
isPermanent
final static Boolean isPermanent(Error $self)
Returns true if an error is a permanent failure instead of a temporary one (broken network, 500, rate limit etc.)
A permanent error is an error returned by Stream's API (IE a validation error on the input) Any permanent error will always have a stream error code
Temporary errors are retried. Network not being available is a common example of a temporary error.
See the error codes here https://getstream.io/chat/docs/api_errors_response/?language=js
-
isMessageAlreadyExists
final static Boolean isMessageAlreadyExists(Error $self)
- Returns:
If the error reports that the message being sent is already stored on the server, which happens when a send that did reach the backend is retried. The backend answers with the generic validation code shared by every input error, so the message shape has to be matched as well.
-
copyWithMessage
final static Error copyWithMessage(Error $self, String message)
Copies the original Error objects with custom message.
- Parameters:
message- The message to replace.- Returns:
New Error instance.
-
extractCause
final static Throwable extractCause(Error $self)
Extracts the cause from Error object or null if it's not available.
- Returns:
The Throwable that is the error's cause or null if not available.
-
-
-
-