Skip to main content

Extra: Known exceptions

rook-sdk returns custom exceptions wrapped in a Future object in each function when an issue is encountered. Below there is a list of all ROOK exceptions, their description/cause 📜 and how to handle them if encountered 🔧.

DateNotValidForEventsException​

📜 The provided DateTime is not in the allowed range to extract events.

🔧 Use a valid DateTime; between 29 days (inclusive) and today (inclusive).

DateNotValidForSummariesException​

📜 The provided DateTime is not in the allowed range to extract events.

🔧 Use a valid DateTime; between 29 days ago (inclusive) and yesterday (inclusive).

DeviceNotSupportedException​

📜 The requested operation could not be completed because the current device is not supported by Health Connect.

🔧 Don't use Health Connect operations, follow the instruction in Availability documentation to easily identify incompatible devices.

HealthConnectNotInstalledException​

📜 The requested operation could not be completed because Health Connect is not installed, starting from Android 14, Health connect is preinstalled on all devices, so this will only happen on Android 13 or lower devices.

🔧 Ask the user to download Health Connect, you can use a package like url_launcher to directly open the PlayStore on the Health Connect page.

void downloadHealthConnect() async {
try {
await launchUrl(Uri.parse(
'https://play.google.com/store/apps/details?id=com.google.android.apps.healthdata',
));
} catch (ignored) {
// Ignored
}
}

HttpRequestException​

📜 An HTTP request failed, this usually means an error in ROOK servers.

🔧 Check if you configured the SDK credentials correctly, if that is OK look for the code and error properties and send a report to ROOK support.

MissingAndroidPermissionsException​

📜 The requested operation requires Android permissions which are not granted.

🔧 Go to the Android permissions section in the documentation to check how you can request permissions.

MissingConfigurationException​

📜 A RookConfiguration instance was not provided to a HCRookConfigurationManager.

🔧 Provide the required RookConfiguration instance. More information here.

MissingHealthConnectPermissionsException​

📜 The requested operation requires Android permissions which are not granted.

🔧 Go to the Health Connect permissions section in the documentation to check how you can request permissions.

RequestQuotaExceededException​

📜 The Health Connect rate limited request quota has been exceeded, this will happen if you use the functions of HCRookEventManager or HCRookSummaryManager too many times.

🔧 Wait for a moment before syncing data again, the quota will be partially restored as the time passes so the longer you wait the more quota will be restored, we recommend waiting from 1 to 6 hours.

SDKNotAuthorizedException​

📜 The requested operation requires an authorization level that your clientUUID doesn't have.

🔧 Check if you configured the SDK credentials correctly, if that is OK send a report to ROOK support, some of the features of the SDK require a special level of authorization that are not included in the basic level.

SDKNotInitializedException​

📜 The SDK was not initialized or failed to initialize.

🔧 Call HCRookConfigurationManager.initRook() and wait for a successful result.

ConnectTimeoutException​

📜 An HTTP request waited too long and could not be completed. This can happen because an unavailable or unstable internet connection.

🔧 Check your connectivity and try again.

UserNotDeletedException​

📜 The current user could not be deleted from ROOK servers.

🔧 Call HCRookConfigurationManager.deleteUserFromRook() again.

UserNotInitializedException​

📜 The User was not initialized or failed to initialize.

🔧 Call HCRookConfigurationManager.updateUserID() and wait for a successful result.

UserNotRegisteredException​

📜 There was an error trying to register a user. This will often be an error from the ROOK API.

🔧 Check the exception message, if the message contains a 401 code it could be that your credentials were configured incorrectly or are wrong, fix them and call HCRookConfigurationManager.updateUserID() again. If the message contains an error related to the ROOK servers internal behaviour, send a report to ROOK support.