Error handling
Gracefully handle Nabla SDK errors
API calls error handling
All methods on NablaClient
and NablaMessagingClient
can return an error in their Result
. This error will always be of type NablaException
.
There are 3 types of exceptions you might want to handle specifically:
NablaException.Network
: for a network related error. You probably want to provide the patient with a retry mechanism when this error happensNablaException.Configuration
: for a misconfiguration of the SDKNablaException.Authentication
: when a call toNablaClient.setCurrentUserOrThrow
is missing before calling an authenticated API or when theSessionTokenProvider
failed to get fresh tokens
See all cases in the NablaException class
Handling by UI components
If any error occurs, the Nabla UI component will handle it in one of the following ways.
- If error is global, e.g. we failed to fetch the list of conversation. Component will then show a text message with a retry button.
- If error is not global, e.g. we failed to load a second page of messages. Component will then show a Toast explaining what failed.
Logging
In all cases, errors will also be logged. If you need more control on what's logged and want to enable DEBUG logs, you can do it during the SDK initialization:
NablaClient.initialize(
configuration = Configuration(
logger = LogcatLogger(logLevel = LogcatLogger.LogLevel.DEBUG),
)
)
Nabla SDK debugging
By default, the SDK will communicate anonymized events with Nabla servers to help us improve features like video calls.
If you want to disable this reporting, you can do so during the SDK initialization:
NablaClient.initialize(
configuration = Configuration(
enableReporting = false,
)
)
As another option, you can instead stripe out the whole reporting tool from your dependencies by adding the following snippet to your application's build.gradle
file:
configurations.implementation {
exclude(group = "com.nabla.sdk", module = "core-reporting")
}
Updated 6 months ago