Skip to content

Errors

Beekon errors are typed (Kotlin: subclasses of BeekonError : Throwable; Swift: cases of enum BeekonError: Error; Dart: subclasses of BeekonException; TypeScript: a BeekonError class with a discriminator kind). No global error state, no error codes — pattern-match the type and act on it.

The set is intentionally small.

ErrorPlatformsWhen it firesWhat to do
PermissionDeniedAllACCESS_FINE_LOCATION not granted (Android), authorization not granted (iOS)Drive the OS permission prompt, retry start()
LocationServicesDisabledAllSystem-wide location services off; on Android, also fires when Google Play Services is missing or out of dateShow a “turn on Location Services” hint and surface gracefully
StorageFailure(cause)AllA SQLite or filesystem failure occurred while reading or writing historyLog cause and surface; should be rare

These three are the entire surface — there’s no NotInitialised, no NotConfigured, no ServiceFailed, no InternalError. Calling start() without prior configure(...) simply uses the persisted last-known config (or BeekonConfig.default on a fresh install). On Android, the foreground service is started as part of start(); if the OS later kills it, you observe that as a state transition rather than a thrown error (see below).

suspend fun startTracking() {
try {
Beekon.start()
} catch (e: BeekonError.PermissionDenied) {
requestLocationPermissions { granted -> if (granted) startTracking() }
} catch (e: BeekonError.LocationServicesDisabled) {
showAlert("Turn on Location Services and ensure Google Play Services is up to date.")
} catch (e: BeekonError.StorageFailure) {
Log.e("beekon", "storage failure", e.cause)
}
}

A useful distinction: errors are thrown when an operation cannot proceed; Stopped states are reported when tracking was running and an external precondition changed.

ScenarioSurface
User has never granted permission, you call start()throws PermissionDenied
User revokes permission while trackingstate transitions to Stopped(PermissionDenied) — no exception is thrown
Android OS kills the foreground service under memory pressurestate transitions to Stopped(System) — Android only

Both code paths exist. Observe the state stream for the runtime-revocation case and try/catch around start() calls. Beekon does not auto-resume after a stop — the host app calls start() again once the underlying condition recovers.

  • Per-fix errors (e.g. one bad fix from the OS provider). Beekon doesn’t filter these — see Locations.
  • Notification-channel errors on Android. Beekon creates the channel and continues even if it can’t be displayed.
  • Foreground-service start failures on Android. These surface as Stopped(System) rather than a thrown error.