handleSuggestedEntitiesQuery method
Gets suggested entities using the registered handler.
This method is called internally when a suggested entities request is received from iOS, and can also be called directly for testing.
Throws AppIntentError if no handler is registered for the entity type.
Implementation
Future<List<Map<String, dynamic>>> handleSuggestedEntitiesQuery(
String entityIdentifier,
) async {
final handler = _suggestedEntitiesHandlers[entityIdentifier];
if (handler == null) {
throw AppIntentError.fromCode(
AppIntentErrorCode.entityQueryHandlerNotFound,
message:
'No suggested entities handler registered for: $entityIdentifier',
details: {'entityIdentifier': entityIdentifier},
);
}
try {
return await handler();
} catch (e) {
if (e is AppIntentError) rethrow;
throw AppIntentError(
code: 'query_error',
message: 'Error getting suggested entities: $e',
details: {'entityIdentifier': entityIdentifier, 'error': e.toString()},
);
}
}