Error Handling

Error Codes

Error objects can be returned to you via LiveObjects, callbacks, or clientErrorDelegate. All the errors returned by the SDK come in form of an Error with domain ASC. The possible error codes are listed in a public ErrorCode enum: each case is named after its error and they're pretty self-explanatory.

Server Errors

Code
Error Name
Description
400000
BadRequestError
Request contains invalid parameters.
400100
UnauthorizedError
Unverified user performs any action that requires access token verification.
400300
ForbiddenError
User performs forbidden action such as uploading a pdf file in an image message.
400301
PermissionDenied
User has no permission to perform the action.
400302
UserIsMuted
A muted user sends a message.
400303
ChannelIsMuted
User sends a message in a muted channel.
400304
UserIsBanned
User accessed a channel or community where he is banned.
400307
MaxRepetitionExceed
User reached the limit of the number of sent messages containing blocklisted words.
400308
BanWordFound
User sends a message that contains a blocklisted word.
400309
LinkNotAllowed
User sends a message that contains link that is not in the Allowlist.
400312
GlobalBanError
Banned user performs any action.
400400
ItemNotFound
System cannot find any resource matched with the requested condition.
400900
Conflict
System cannot create/update duplicated data.
500000
BusinessError
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
InvalidParameter
Data type of the parameter is invalid.
800210
ConnectionError
Websocket connection of the SDK cannot reach the platform server. This could also be the case if a user is global-banned and tries to register a session.
When a user gets disconnected from the system due to connection problems or actions such as banning the user, reconnection to the platform can only be established again after performing a page refresh.
You can log errors in the console with the following:
1
import { ErrorCode, CommunityRepository } from '@amityco/js-sdk'
2
3
const liveObject = CommunityRepository.communityForId('abc');
4
liveObject.on("dataUpdated", data => {
5
// community is fetched
6
});
7
liveObject.on("dataError", err => {
8
// failed to fetch the community
9
console.log(err.code == ErrorCode.BusinessError);
10
}
Copied!
When an error is returned as a result of an action from your side (e.g. trying to join a channel), the action is considered completed and the SDK will not execute any additional logic.

Asynchronous Errors

The ASCClient includes a clientErrorDelegate property that can be set to an error handler delegate class on your application. This error delegate gives you a chance to be notified of errors that can potentially break the functionality of the SDK. The SDK logic is usually robust enough to automatically handle most errors, as such, only unrecoverable errors are exposed through this delegate (for example, if the login session was invalidated).
We recommend you to always handle these errors in a production app by gracefully disabling messaging functionality in the event of an error.
Last modified 1mo ago