Error logging
Chat SDK records all errors by default (errorLogger) from initialization until app closure. Download logs as a TXT file containing JSON (use a formatter for readability).
Each session log contains the PUBNUB_INTERNAL_ERROR_LOGGER constant, session ID, and error list. Error structure:
keylisting the method that caused the error and the object on which it was called.errorcontaining the exact error message.thrownFunctionArgumentsshowing the method arguments the error relates to.
In this example, an error is returned when you try to retrieve channel details without providing the channel ID that is required in this Chat SDK method.
{
"PUBNUB_INTERNAL_ERROR_LOGGER_1691586109386":[
{
"key":"Chat.getChannel",
"error":"ID is required",
"thrownFunctionArguments":{
"0":""
}
}
]
}
In this example, you want to create a public channel, and the channel ID is too long as it exceeds the 92 UTF-8 characters allowed by PubNub.
{
"PUBNUB_INTERNAL_ERROR_LOGGER_1691586109386":[
{
"key":"Chat.createPublicConversation",
"error":{
"name":"Error",
"message":"PubNub call failed, check status for details",
"status":{
"error":true,
"operation":"PNSetChannelMetadataOperation",
"statusCode":400,
"errorData":{
"status":400,
"error":{
"message":"Invalid request input.",
show all 36 linesDownload error log
Download a file containing session errors from a web app.
Method signature
1chat.downloadDebugLog(): void
Input
This method doesn't take any parameters.
Output
| Type | Description |
|---|---|
void | Method does not return any value. It allows you to add additional logic and download a text file with logs from a web app. |
Sample code
Download the current error log.
1chat.downloadDebugLog()