Skip to main content
Version: 5.9.0

Error reference

SDK methods throw two error types: ChatCenterUIError (chat operations) and ChatCenterUISendMessageError (message sending).

Chat errors (ChatCenterUIError)

Thrown by chat-related methods.

ErrorDescriptionCauseRecommendation
.userNotAuthorizedThe user is not authorizedThe method was called before authorize(user:) or after logout() / deauthorizeUser()Call authorize(user:) before using the method
.chatNotOpenedThe chat screen is not open, or userInfo is emptyhandleNotification(userInfo:) was called while the chat is not displayed, or the userInfo dictionary is emptyThis is expected behavior. Use getChat(userInfo:) to open the chat with the notification context. See Notifications for details

Which methods throw ChatCenterUIError

MethodPossible errors
getChat(userInfo:).userNotAuthorized
logout().userNotAuthorized
getUnreadMessagesCount(completion:).userNotAuthorized
handleNotification(userInfo:).chatNotOpened

Handling example

do {
let chatController = try chatCenterSDK.getChat()
navigationController?.pushViewController(chatController, animated: true)
} catch ChatCenterUIError.userNotAuthorized {
// User is not authorized — show the login screen
showLoginScreen()
} catch {
print("Unexpected error: \(error)")
}
Checking authorization before the call

The SDK does not expose a public isAuthorized() or currentUser() method. Track the authorization state on the application side: set a flag on a successful authorize(user:) and clear it on logout() / deauthorizeUser(). Or catch .userNotAuthorized via do/catch (see the example above).

do {
try chatCenterSDK.handleNotification(userInfo: userInfo)
} catch ChatCenterUIError.chatNotOpened {
// Chat is not open — open it with the notification context
do {
let chatController = try chatCenterSDK.getChat(userInfo: userInfo)
navigationController?.pushViewController(chatController, animated: true)
} catch {
print("Error opening chat: \(error)")
}
} catch {
print("Error handling notification: \(error)")
}

Message sending errors (ChatCenterUISendMessageError)

Thrown by the send(message:) method.

ErrorDescriptionCauseRecommendation
.userNotAuthorizedThe user is not authorizedauthorize() was not calledCall authorize(user:) before sending
.webSocketNotActiveThe WebSocket connection is not activeChat is closed without keepSocketActive, no network, or the connection has not been established yetSee solutions below
.messageIsEmptyThe message text is emptyAn empty string was passed in .text("")Validate the text before sending
.messageTooLongThe text exceeds 4000 charactersThe message is too longTrim the message to 4000 characters
.messageImageTooLargeThe JPEG size exceeds the server limit (30 MB by default)The limit is configured server-sideReduce the image resolution before sending
.messageImageCompressionErrorImage compression failedInvalid or corrupted UIImageValidate the UIImage object

send(message:) does not throw .chatNotOpened or .messageNotSent — no handling is needed.

Handling example

do {
try chatCenterSDK.send(message: .text("Hello"))
} catch ChatCenterUISendMessageError.webSocketNotActive {
// WebSocket is not active — store the message for later sending
pendingMessages.append(message)
} catch ChatCenterUISendMessageError.messageTooLong {
// Trim and retry
let trimmed = String(text.prefix(4000))
try? chatCenterSDK.send(message: .text(trimmed))
} catch {
// Other validation errors
print("Send error: \(error)")
}
Transient network errors

Network delivery errors are not delivered as ChatCenterUISendMessageErrorsend(message:) only checks preconditions (authorization, WebSocket state, content validity).

For REST-layer errors (including file uploads), use ChatCenterUISDKDelegate.chatCenterUI(chatCenter:didReceiveNetwork:) — see SDK Delegate.

WebSocket drops and errors are not delivered through this delegate callback. Track the WebSocket status via send(message:) — it throws .webSocketNotActive when the channel is inactive. To keep the channel active outside the chat screen, enable keepSocketActive (Chat configuration).


Relation between .webSocketNotActive and keepSocketActive

By default, the WebSocket connection is active only while the chat screen is open. Sending via send(message:) without an open chat will fail with .webSocketNotActive.

Solutions

ApproachSettingWhen to use
Persistent connectionchatConfig.keepSocketActive = trueBackground sending, unread counter
Connection during a sessionchatConfig.keepSocketActiveDuringOperatorSession = trueNotifications during an active dialog
Send only inside the chatNo additional settingsWhen background sending is not needed
Local flags are scheduled for removal

In future SDK versions, keepSocketActive and keepSocketActiveDuringOperatorSession will be replaced by a server-side channelConfig (requested from edna technical support). For new code, prefer the server-side path.

Local values only take effect when chatConfig.shouldUseRemoteConfig = false. With the default (true), the server-side config overrides them. See SDK configuration for details.


Diagnosing errors

Enable logging when initializing the SDK:

let loggerConfig = ChatLoggerConfig(logLevel: .all)
let chatCenterSDK = ChatCenterUISDK(providerUid: "...",
chatConfig: chatConfig,
loggerConfig: loggerConfig)

See Logger configuration for details.