nativeTaskFailure function

Object nativeTaskFailure(
  1. Object error
)

Rewrites an unresolvable native symbol into an actionable failure.

When no MediaPipe runtime is bundled, dart:ffi fails with a bare ArgumentError naming an internal asset id. That message tells an application nothing about the remedy, so native task creation reports the missing artifact instead. Every other error is returned unchanged.

Implementation

Object nativeTaskFailure(Object error) {
  final String description = error is Error ? '$error' : error.toString();
  if (!description.contains('native function') ||
      !description.contains('Attempted to fallback to process lookup')) {
    return error;
  }
  return const MpException(
    MpStatus.unavailable,
    'No MediaPipe native runtime is linked into this build. Published packages '
    'bundle a checksummed runtime per platform; a source checkout can point the '
    'mp_core native asset hook at a local build with the '
    '`native_library_directory` user define (for example `.mp-sdk`). The web '
    'adapter needs no native runtime and is selected automatically for browser '
    'builds.',
  );
}