handleEntityQuery method
Queries entities using the registered handler.
This method is called internally when an entity query 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>>> handleEntityQuery(
String entityIdentifier,
List<String> identifiers,
) async {
final handler = _entityQueryHandlers[entityIdentifier];
if (handler == null) {
throw AppIntentError.fromCode(
AppIntentErrorCode.entityQueryHandlerNotFound,
message: 'No entity query handler registered for: $entityIdentifier',
details: {'entityIdentifier': entityIdentifier},
);
}
try {
return await handler(identifiers);
} catch (e) {
if (e is AppIntentError) rethrow;
throw AppIntentError(
code: 'query_error',
message: 'Error querying entities: $e',
details: {'entityIdentifier': entityIdentifier, 'error': e.toString()},
);
}
}