Error Handling

Error Codes

All the errors returned by the SDK come in form of an AmityException. The possible error codes are listed in a public AmityError enum: each case is named after its error and they are designed to be self explanatory.

Server Errors

Code
Error Name
Description
400000
BAD_REQUEST_ERROR
Request contains invalid parameters.
400100
UNAUTHORIZED_ERROR
Unverified user performs any action that requires access token verification.
400300
FORBIDDEN_ERROR
User performs forbidden action such as uploading a pdf file in an image message.
400301
PERMISSION_DENIED
User has no permission to perform the action.
400302
USER_IS_MUTED
A muted user sends a message.
400303
CHANNEL_IS_MUTED
User sends a message in a muted channel.
400304
USER_IS_BANNED
User accessed a channel or community where he is banned.
400307
MAX_REPETITION_EXCEED
User reached the limit of the number of sent messages containing blocklisted words.
400308
BAN_WORD_FOUND
User sends a message that contains a blocklisted word.
400309
LINK_NOT_ALLOWED
User sends a message that contains link that is not in the Allowlist.
400312
USER_IS_GLOBAL_BANNED
Banned user performs any action.
400400
ITEM_NOT_FOUND
System cannot find any resource matched with the requested condition.
400900
CONFLICT
System cannot create/update duplicated data.
500000
BUSINESS_ERROR
Uncategorized internal system errors not related to any user input.

Client Errors

Code
Error Name
Description
800000
UNKNOWN
Uncategorized errors.
To debug, refer to the 'error.message' property.
800110
INVALID_PARAMETER
Data type of the parameter is invalid.
800210
CONNECTION_ERROR
Websocket connection of the SDK cannot reach the platform server. This could also be the case if a user is global-banned and try to register a session.
You can convert an AmityException into AmityError enum with the following:
1
if (AmityError.from(throwable) == AmityError.CHANNEL_IS_MUTED) {
2
// Couldn't send a message to this channel because this channel is muted.
3
}
Copied!
When an error is returned as a result of an action from your side (e.g. trying to join a channel), the action can considered complete, and the SDK will not execute any additional logic.

Global ban error handling

AmityError.USER_IS_GLOBAL_BANNED is an error indicating that the user is banned from the system resulting in an inability to have a connection with the system. If the user already has a session, the session will be revoked and will be unable to create a new session.
In case the user is banned while not having a session, the error can be observed from the session creation API
1
AmityCoreClient.registerDevice("userId")
2
.build()
3
.submit()
4
.doOnError {
5
if (AmityError.from(it) == AmityError.USER_IS_GLOBAN_BANNED) {
6
// handle the case the user is globally banned
7
}
8
}
9
.subscribe()
Copied!
In case the user is banned while already having a session, the error can be observed from the global ban events API
1
// Subcription can be done after a session is created
2
// and lives through the remaining Application lifecycle
3
AmityCoreClient.getGlobalBanEvents()
4
.doOnNext {
5
// handle the case the user is globally banned
6
}
7
.subscribe()
Copied!
Last modified 3mo ago