onCommandFailure method

  1. @override
Future<void> onCommandFailure(
  1. Command command,
  2. dynamic error
)

Called when command processing fails Override to handle command failures

Implementation

@override
Future<void> onCommandFailure(Command command, dynamic error) async {
  await super.onCommandFailure(command, error);

  // Send error response to sender if running in actor system
  final sender = _capturedSenders[command.commandId];
  if (sender != null) {
    // Send error wrapped in LocalMessage
    sender.tell(LocalMessage(payload: {
      'success': false,
      'error': error.toString(),
      'commandId': command.commandId,
    }));
    // Clean up captured sender
    _capturedSenders.remove(command.commandId);
  }
}