Error Handling

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.
You can log errors in the console with the following:
1
import React, { useState, useEffect } from 'react'
2
import './index.css'
3
import { observeMessage } from "@amityco/ts-sdk";
4
5
export default function MessageContent({ messageId }: { messageId: string }) {
6
const [messageResult, setMessageResult] = useState<Amity.QueryResult<Amity.Message | undefined>>()
7
const { data: message, loading, error } = messageResult;
8
9
useEffect(
10
() => observeMessage(messageId, setMessageResult),
11
[messageId],
12
);
13
14
if (error)
15
return null // get the error object here
16
17
// else continue as natural
18
}
19
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.

Global ban error handling

Amity.ServerError.GLOBAL_BAN 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.
1
import { onConnectionError } from '@amityco/ts-sdk'
2
3
onConnectionError((error) => {
4
if (error.code === Amity.ServerError.GLOBAL_BAN)
5
console.log('user has been globally banned!')
6
})
Copied!
Last modified 1mo ago
Export as PDF
Copy link