Saltar al contenido principal

Error Handling

When interacting with the Eixam Connect SDK, exceptions are thrown to indicate configuration errors, network failures, or invalid state.

You should always wrap SDK calls in try-catch blocks and handle specific Eixam exceptions appropriately.

Common Exceptions

The SDK surfaces strongly-typed exceptions to help you identify the failure mode.

ExceptionCauseResolution
UnsupportedErrorEixamConnectSdk.bootstrap(...) was called without importing the Flutter package entrypoint that registers the bootstrapper.Import package:eixam_connect_flutter/eixam_connect_flutter.dart before calling bootstrap.
ArgumentErrorInvalid bootstrap config, such as empty appId, missing custom endpoints for custom, or initialSession.appId mismatch.Validate config before bootstrap and keep appId consistent.
AuthExceptionThe active signed session is missing, invalid, expired, or rejected.Clear the session and fetch a new signed session from your backend.
NetworkExceptionThe SDK could not reach the API or realtime transport.Check connectivity and retry with backoff where appropriate.
DeviceExceptionDevice pairing, activation, BLE command, or device runtime state is invalid for the attempted operation.Check permissions, Bluetooth state, connection state, and command readiness before retrying.
SosException / SosHttpExceptionSOS state, transport, or HTTP fallback failed.Inspect code, message, and statusCode when present; show a recoverable flow when another SOS channel remains available.
TrackingExceptionLocation/tracking state or permission is invalid.Check location permissions and tracking state.
ContactsException / ContactsHttpExceptionContact list or mutation failed.Inspect HTTP fields on ContactsHttpException; refresh contact state after successful mutations.
DeathManExceptionDMP scheduling/check-in/cancel state is invalid.Refresh the active plan and retry from the latest state.
ProfileHttpExceptionSDK profile GET/PUT /v1/sdk/me failed.Inspect HTTP fields and fieldHints; map field hints into form errors.

Profile HTTP (GET/PUT /v1/sdk/me)

For fetchSdkUserProfile() and updateSdkUserProfile(), failures are surfaced as ProfileHttpException (extends EixamSdkException). Inspect:

FieldUse
statusCodeHTTP status from the platform
codeSDK-side classification code on the exception
messageHuman-readable summary
apiErrorCode / apiErrorMessageParsed platform error envelope when present
fieldHintsList of SdkProfileApiFieldHint tying backend messages to name, email, phone, or address when the API provides field-level hints
rawBodyOptional raw response body for diagnostics

Prefer mapping fieldHints onto your form fields for inline errors; fall back to apiErrorMessage or message for banner-level messaging. For invalid payloads, validate locally first using SdkProfileValidators so you can avoid round-trips when fields violate documented constraints (length, E.164 phone, email format).

See also: Get SDK user profile, Update SDK user profile.

Emergency contacts HTTP (/v1/sdk/contacts)

Contact list and mutation failures are surfaced as ContactsHttpException (extends EixamSdkException) when the SDK HTTP layer can classify the response. Typical mappings:

HTTP statusSDK code (examples)When
400E_SDK_CONTACTS_VALIDATIONInvalid body, unknown id, or incomplete reorder payload (must include every contact id exactly once)
401E_SDK_CONTACTS_UNAUTHORIZEDMissing/invalid signed session for SDK HTTP
404E_SDK_CONTACTS_NOT_FOUNDUpdate/delete for a contact that does not exist for the user

Inspect statusCode, code, message, and optional apiErrorMessage for user-visible copy. Prefer refreshing listEmergencyContacts() / watchEmergencyContacts() after a successful reorder or delete so UI matches the server.

Diagnosing Real-Time Issues

For MQTT/real-time specific failures, use sdk.watchOperationalDiagnostics() to observe transport-level states without throwing exceptions directly into the UI.

sdk.watchOperationalDiagnostics().listen((diagnostics) {
if (diagnostics.connectionState != RealtimeConnectionState.connected) {
print('Warning: Real-time telemetry is degraded.');
}
});