execute method

  1. @override
Future execute(
  1. String? correlationId,
  2. Parameters args
)
override

Executes the command. Before execution it validates Parameters args using the defined schema. The command execution intercepts exceptions raised by the called function and returns them as an error in callback.

  • correlationId (optional) transaction id to trace execution through call chain.
  • args the parameters (arguments) to pass to this command for execution. Return Future when command is complete See Parameters

Implementation

/// - correlationId (optional) transaction id to trace execution through call chain.
/// - args          the parameters (arguments) to pass to this command for execution.
/// Return          Future when command is complete
/// See [Parameters]
@override
Future<dynamic> execute(String? correlationId, Parameters args) async {
  if (schema_ != null) {
    schema_!.validateAndThrowException(correlationId, args);
  }

  try {
    var result = await _function(correlationId, args);
    return result;
  } catch (ex) {
    throw InvocationException(correlationId, 'EXEC_FAILED',
            'Execution ' + getName() + ' failed: ' + ex.toString())
        .withDetails('command', getName())
        .wrap(ex);
  }
}