Errors
The calls that wait for the chat report a failure as an error you can catch: sendMessage, authenticate and deauthenticate on iOS and Android, and in Flutter and React Native every call that returns a future or a promise. The calls that return nothing on iOS and Android, such as displayChat, triggerDialogue and setNewContext, report a refused call in the Logging and Crash Reporting instead
Error codes
Meaning | iOS KindlyWebViewError | Android KindlyWebViewException | Flutter KindlyWebViewErrorCode | React Native code |
|---|---|---|---|---|
start was not called, or kill ran since | notStarted | NotStarted | notStarted | NOT_STARTED |
No chat page is loaded. Show the chat first | chatNotReady | ChatNotReady | chatNotReady | CHAT_NOT_READY |
An argument was refused. The error names the argument, never its value | invalidArgument(_:) | InvalidArgument | invalidArgument | INVALID_ARGUMENT |
authenticate() was called, but start got no auth provider | noAuthProvider | NoAuthProvider | nativeError | NATIVE_ERROR |
The chat page did not answer in time | timeout | Timeout | nativeError | NATIVE_ERROR |
The chat widget refused or failed the call | widgetError(code:) | WidgetError | nativeError | NATIVE_ERROR |
This device or app cannot run the chat | unsupported | Unsupported | unsupported | UNSUPPORTED |
Android only: there was no context to show the chat from | | | noActivity | NO_ACTIVITY |
The widget error's code is unknown_command, widget_error or unknown, never text from the page
Handling an error
Task {
do {
try await KindlyWebViewSDK.sendMessage("Where is my order?")
} catch let error as KindlyWebViewError {
switch error {
case .chatNotReady:
KindlyWebViewSDK.displayChat()
case let .invalidArgument(name):
print("Kindly refused \(name)")
default:
print(error.localizedDescription)
}
} catch {
print(error.localizedDescription)
}
}KindlyWebViewError can gain cases in a later version, so give a switch over it a default or @unknown default case. endChat() and kill() are async and never throw
The error messages never contain a token, a chat id, a URL or message text, so they are safe to log