mapError static method

  1. @visibleForTesting
Object mapError(
  1. Object error
)

Turns a native error into the matching FacePingException; anything else is rethrown as it is.

Implementation

@visibleForTesting
static Object mapError(Object error) {
  if (error is! PlatformException) return error;
  final message = error.message ?? error.code;
  return switch (error.code) {
    'setup' => FacePingSetupException(message),
    'model' => FacePingModelException(message),
    'invalidOperation' => FacePingInvalidOperationException(message),
    'invalidArgument' => FacePingInvalidArgumentException(message),
    'storage' => FacePingStorageException(message),
    'camera' => FacePingCameraException(message),
    'canceled' => FacePingCanceledException(message),
    _ => error,
  };
}