Handle Execption
The LikeMinds Chat SDK provides a built-in logging system that captures and reports errors encountered during execution of our SDK. This system allows developers to configure logging preferences, handle errors effectively, and optionally share logs with LikeMinds for debugging purposes.
The handleException()
method in LMChatLogger is responsible for capturing, logging and handling errors that occur within the application. It ensures that errors are recorded locally and handled as well.
Steps to Handle Execption
you can log errors using the handleException()
method. This method captures error details and processes them according to the logging configuration.
- To log and handle an execption, use the
handleException()
method on the LMChatClient instance. - Pass the required parameters:
exception
,stackTrace
andseverity
. - The log is saved in the Realm database and can be retrieved later using getLogs().
Example Usage
lmChatClient?.handleException(
error,
{
exception: error,
trace: error?.stack,
},
LMSeverity.ERROR // severity of the error encountered
);
Handle Exception Parameters
Parameter | Type | Description |
---|---|---|
exception | Error | The error object to be logged. |
stackTrace | LMStackTrace | Contains exception message and trace . |
severity | LMSeverity | The severity level of the error (INFO, ERROR, etc.). |