Error Management
Errors that happen in the context of the SDK are wrapped in a type of exception: D2Error
, with the following fields:
Attribute | Type | Optional | Description |
---|---|---|---|
errorComponent | D2ErrorComponent | true | Source of the error: Database, SDK or Server. |
errorCode | D2ErrorCode | true | SDK-defined unique error code. |
errorDescription | String | true | Description of the error in english (technical details, just for logs and debugging). |
httpErrorCode | Integer | false | If caused by HTTP request, HTTP error code. |
originalException | Exception | false | Original Java Exception causing the error, if any. |
Any operation requested to the SDK can throw an error.
For operations returning RxJava objects, the errors can be extracted in the following way:
For blocking operations, it is also possible to retrieve a
D2Error
. The errors can be extracted by caching them as shown in the following code snippet:
D2Errors
are persisted in the Database when they occur, so they can be
analyzed afterwards and diagnose possible problems. They can be accessed
through it's own repository:
The SDK team is now working together with the core team in order to provide a full list of common error codes, but it's still a work in progress.