mapPlatformException function
Converts a native error into the matching typed exception.
Implementation
OnDeviceAiException mapPlatformException(PlatformException e) {
final message = e.message ?? e.code;
return switch (e.code) {
'UNAVAILABLE' => OnDeviceAiUnavailableException(message),
'UNSUPPORTED' => OnDeviceAiUnsupportedException(message),
'CANCELLED' => OnDeviceAiCancelledException(message),
'SESSION_BUSY' => OnDeviceAiSessionBusyException(message),
'USER_ACTIVATION_REQUIRED' => OnDeviceAiUserActivationRequiredException(
message,
),
_ => OnDeviceAiGenerationException(message),
};
}