answer static method

void answer(
  1. Object? message,
  2. FutureOr<Object?> run(
    1. List<Object?> message
    )
)

Runs run with the message of a send and answers it. An error is not thrown here (it would stop the serving isolate). The caller gets a StateError with no details, so no data ends up in a log.

Implementation

static void answer(
  Object? message,
  FutureOr<Object?> Function(List<Object?> message) run,
) async {
  List<Object?> m = message as List<Object?>;
  SendPort reply = m[0] as SendPort;
  Object? id = m[1];
  try {
    reply.send(<Object?>[id, await run(m.sublist(2))]);
  } catch (_) {
    reply.send(<Object?>[id, null, false]);
  }
}