Skip to main content
let uid = "UID";
let authKey = "AUTH_KEY";

// All errors are CometChatException objects
try {
  await CometChat.login(uid, authKey);
} catch (error) {
  console.log(error.code);    // e.g., "AUTH_ERR_AUTH_TOKEN_NOT_FOUND"
  console.log(error.name);    // e.g., "AUTH_ERR_AUTH_TOKEN_NOT_FOUND"
  console.log(error.message); // Human-readable description
  console.log(error.details); // Additional context (if available)
}
Error categories: Initialization, Login, Calling, Messages, Groups, Users, Conversations, Receipts, AI, Extensions
Every error thrown by the CometChat SDK is a CometChatException object with four properties:
PropertyTypeDescription
codestring | numberMachine-readable error code
namestringError name (often matches code)
messagestringHuman-readable description
detailsstringAdditional context or troubleshooting info
try {
  const user: CometChat.User = await CometChat.login(authToken);
} catch (error: CometChat.CometChatException) {
  switch (error.code) {
    case "AUTH_ERR_AUTH_TOKEN_NOT_FOUND":
      // Token is invalid or expired — prompt re-login
      break;
    case "MISSING_PARAMETERS":
      // A required parameter was not provided
      break;
    default:
      console.error("Unexpected error:", error.message);
  }
}

Initialization Errors

CodeMessage
MISSING_PARAMETERSAppID cannot be empty. Please specify a valid appID.

Login & Authentication Errors

CodeMessage
COMETCHAT_INITIALIZATION_NOT_DONEPlease initialize CometChat before using the login method.
USER_NOT_AUTHORISEDThe authToken of the user is not authorised. Please verify again.
AUTH_ERR_AUTH_TOKEN_NOT_FOUNDThe auth token does not exist. Please make sure you are logged in and have a valid auth token.
LOGIN_IN_PROGRESSPlease wait until the previous login request ends.
WS_CONNECTION_FAILWebSocket connection failed.
WS_CONNECTION_FALLBACK_FAILWebSocket connection fallback failed.
WS_AUTH_FAILWebSocket username/password not correct.
NO_INTERNET_CONNECTIONYou do not have an internet connection.
USER_NOT_LOGGED_INPlease log in to CometChat before calling this method.

Calling Errors

CodeMessage
CALL_ALREADY_INITIATEDThere is already a call in progress.
CALL_IN_PROGRESSThere is already a call in progress.
NOT_INITIALIZEDPlease call CometChat.init() before calling any other methods.
NOT_LOGGED_INPlease login before starting a call.
SESSION_ID_REQUIREDPlease make sure you are passing a correct session ID.
CALL_SETTINGS_REQUIREDPlease make sure you are passing the call settings object.
JWT_NOT_FOUNDThere was an issue while fetching JWT from API.

Message Errors

CodeMessage
INVALID_RECEIVER_TYPEReceiver type can be user or group.
REQUEST_IN_PROGRESSRequest in progress.
NOT_ENOUGH_PARAMETERSTimestamp, MessageId, or updatedAfter is required to use fetchNext().
INVALID_REASON_IDInvalid reasonId provided.

User Errors

CodeMessage
INVALID_STATUS_VALUEThe status parameter accepts only online or offline.
INVALID_DIRECTION_VALUEThe direction parameter accepts only both, blockedByMe, or hasBlockedMe.
EMPTY_USERS_LISTThe users list needs to have at least one UID.

Group Errors

CodeMessage
NOT_A_GROUPPlease use the Group class to construct a new group.
INVALID_SCOPE_VALUEScope can be admin, moderator, or participant.
INVALID_GROUP_TYPEGroup type can be public, private, protected, or password.
ERR_EMPTY_GROUP_PASSPassword is mandatory to join a group.

Conversation Errors

CodeMessage
INVALID_CONVERSATION_TYPEConversation type can be user or group.
CONVERSATION_NOT_FOUNDConversation not found. Check the value of conversationWith and conversationType.

Receipt Errors

CodeMessage
MISSING_PARAMETERSExpected 4 parameters, received 3.
NO_WEBSOCKET_CONNECTIONConnection to WebSocket server is broken. Please retry after some time.
RECEIPTS_TEMPORARILY_BLOCKEDDue to high load, receipts have been blocked for your app.
UNKNOWN_ERROR_OCCURREDUnknown error occurred while marking a message as read.

AI Feature Errors

CodeMessage
NO_CONVERSATION_STARTERUnable to get conversation starter for this conversation.
NO_SMART_REPLYUnable to get smart reply for this conversation.
NO_CONVERSATION_SUMMARYUnable to get summary of the conversation.
EMPTY_RESPONSEUnable to get a suggestion.
ERROR_INVALID_AI_FEATUREThe provided AI Feature cannot be null or empty.

Extension Errors

CodeMessage
ERROR_INVALID_EXTENSIONThe provided extension cannot be null or empty.
ERROR_EXTENSION_NOT_FOUNDThe provided extension could not be found.

Feature Restriction Errors

CodeMessage
ERROR_INVALID_FEATUREThe provided feature cannot be null or empty.
ERROR_FEATURE_NOT_FOUNDThe provided feature could not be found.

Network & API Errors

CodeMessage
FAILED_TO_FETCHThere is an unknown issue with the API request. Check your internet connection.
TOO_MANY_REQUESTToo many requests. Wait before sending the next request.
ERR_TOO_MANY_REQUESTSRate limiting. See Rate Limits.

Validation Errors

These errors use dynamic codes based on the parameter name (e.g., INVALID_UID, UID_IS_COMPULSORY):
PatternMessage
INVALID_{param}The parameter should be a string / number / boolean / object / array.
{param}_IS_COMPULSORYThe parameter cannot be blank. Please provide a valid value.
{param}_NOT_PROVIDEDPlease provide the required parameter.
ERROR_{param}_EXCEEDEDLimit exceeded max limit.
INVALID_SEARCH_KEYWORDInvalid search keyword. Please provide a valid search keyword.
MISSING_KEYThe key is missing from the object.

Prosody (WebSocket Server) Errors

CodeMessage
ERROR_INVALID_SESSIONIDThe provided sessionId cannot be null or empty.
ERROR_INVALID_TYPEThe provided type cannot be null or empty.
ERROR_INVALID_GROUPLISTGrouplist cannot be null or empty.

General Errors

CodeMessage
ERROR_IO_EXCEPTIONI/O exception occurred.
ERROR_JSON_EXCEPTIONJSON parsing exception.
ERROR_PASSWORD_MISSINGPassword is mandatory for a password group.
ERROR_LIMIT_EXCEEDEDLimit exceeded max limit.
ERROR_INVALID_GUIDPlease provide a valid GUID.
ERR_SETTINGS_HASH_OUTDATEDSettings hash is outdated.
ERR_NO_AUTHNo authentication credentials found.

Server-Side API Errors

For REST API error codes (returned by the CometChat backend), see the Error Guide. Common server-side errors you may encounter in SDK responses:
CodeDescription
AUTH_ERR_EMPTY_APPIDEmpty App ID in headers
AUTH_ERR_INVALID_APPIDInvalid App ID or does not exist in region
ERR_UID_NOT_FOUNDUser does not exist or is soft deleted
ERR_GUID_NOT_FOUNDGroup does not exist
ERR_NOT_A_MEMBERUser is not a member of the group
ERR_ALREADY_JOINEDUser has already joined the group
ERR_MESSAGE_ID_NOT_FOUNDMessage does not exist
ERR_PLAN_RESTRICTIONFeature not available with current plan
ERR_TOO_MANY_REQUESTSRate limit exceeded
See the full list in the Error Guide.

Next Steps

Troubleshooting

Common issues and solutions

Rate Limits

Understand and handle rate limits

Error Guide (REST API)

Complete server-side error code reference

Best Practices

Recommended patterns for error handling