Docs Menu
Docs Home
/ /
Atlas Device SDKs
/ /

Handle Realm Errors - Kotlin SDK

On this page

  • Realm Errors

The Kotlin SDK uses a hierarchy of exceptions to help developers manage API call failures. There are two major categories of exceptions that your application should handle when using the Kotlin SDK:

  • realm errors occur when a read or write to Realm fails. These errors generate a RealmException.

  • app errors occur when network communication with Atlas App Services fails. These errors generate an AppException. For more information on app errors, refer to Handle App Errors. For more information on sync-specific app errors, refer to Handle Sync Errors.

Realm errors occur when a database read or write fails for any reason. When possible, the SDK uses existing platform exceptions, like IllegalArgumentException or IllegalStateException.

Typically, these errors result from bad database logic, such as a query missing an argument, attempting to write outside of a write transaction, or deleting an object that does not exist.

However, some errors are ephemeral: they occur because of failures outside of the client or SDK's control. When an ephemeral error occurs, you should retry the operation that caused the error. If the operation still fails when you retry it, investigate logic fixes.

You can handle errors in the SDK with Kotlin's built-in runCatching API. Use the onSuccess and onFailure callbacks of the returned Result to handle successful SDK API calls and error cases.




Connect to Atlas

On this page