configure method
void
configure(
- dynamic args
Passes args to the module's Configurable.configure method.
Throws ModuleLifecycleException if the module implements Configurable but the argument type does not match.
Implementation
void configure(dynamic args) {
if (_currentStatus != ModuleStatus.initial) {
throw ModuleLifecycleException(
'Module ${module.runtimeType} cannot be configured after initialization has started.',
moduleType: module.runtimeType,
state: _currentStatus,
);
}
if (module is Configurable) {
try {
(module as Configurable).configure(args);
} catch (error) {
// Handle generic type mismatch gracefully or rethrow
// If we pass wrong type to configure(T args), Dart throws TypeError.
final exception = ModuleLifecycleException(
'Module ${module.runtimeType} failed to configure: '
'Expected arguments of correct type for Configurable<T>.\n'
'Error: $error',
moduleType: module.runtimeType,
);
_lastError = exception;
_updateStatus(ModuleStatus.error);
throw exception;
}
}
}