Skip to main content
Robust error handling keeps your EHR integration reliable across patchy networks and unexpected server conditions. The Squire SDK provides a built-in state machine, automatic reconnection logic, and explicit error surfaces so you can respond appropriately at every stage of a consultation.

SDK state machine

Every consultation session moves through a defined set of states. Understanding these transitions helps you drive your UI — for example, showing a spinner during INITIALIZING or a warning banner during RECONNECTING. The possible state values are:

Listen for state changes

Subscribe to the state-change event to receive every transition:

Built-in error handling

The SDK includes retry logic for transient errors such as network interruptions and server errors. If the connection drops while audio is streaming, the SDK enters the RECONNECTING state and continues buffering audio locally. Once the connection is re-established, all buffered audio is sent to the server — no data is lost. If the SDK encounters a non-recoverable error, it emits an error event:

Explicit error handling

startRecording is asynchronous and may reject if the microphone is unavailable, permissions are denied, or the server cannot be reached. Wrap it in a try/catch block to handle these cases gracefully:

Report generation result

After a consultation completes, check the generation_result field in the summary to confirm the report was generated successfully. See the report generation result reference for the list of possible values and how to handle each one.

Log level

Log level configuration was introduced in SDK v1.8.1.
By default, the SDK logs at the info level. You can adjust this when initializing the SDK to get more or less output:
Available log levels, from most to least verbose:
Use debug during development to trace every SDK event, and switch to warn or error in production to reduce noise.