Error Handling

This section shows how to handle NavigationError cases consistently and present clear retry or recovery actions when offline initialization, data, or network conditions fail.

Handle NavigationError cases first:

1
do {
2
try await performOfflineAction()
3
} catch let error as NavigationError {
4
switch error {
5
case .engineNotInitialized:
6
showInitializationRequired()
7
case .dataNotReady, .regionNotFound:
8
showDataUnavailable(error.localizedDescription)
9
case .interrupted, .engineSuperseded:
10
showRetry(error.localizedDescription)
11
default:
12
showOfflineError(code: error.code, message: error.message)
13
}
14
} catch {
15
showOfflineError(code: "unknown", message: error.localizedDescription)
16
}
Error or stateCommon causeRecommended handling
engineNotInitializedInitialization has not been startedCall initializeOffline and retry
invalidConfigDifferent immutable configurations were used during one lifecycleUse one configuration source; start a new lifecycle after a complete shutdown
dataNotReadyRequired routing data has not been downloaded or loadedPrompt the user to download the required region
dataVersionMismatchLocal data is incompatible with the engine's supported rangePrompt the user to update region data and record health diagnostics
interruptedShutdown is in progress or the task was canceledWait for the lifecycle to stabilize and retry
engineSupersededThe engine was replaced while the operation was waitingCheck for duplicate engine creation or shutdown calls
Network unavailable or restrictedNo network connection or the Wi-Fi-only policy is not satisfiedPreserve partial data and provide a recovery action