throwErrorOnPlatformException method

Never throwErrorOnPlatformException(
  1. PlatformException exception
)

Implementation

Never throwErrorOnPlatformException(PlatformException exception) {
  final details = Map<String, Object>.from(
    (exception.details as Map)
        .map<String?, Object?>((k, v) => MapEntry(k?.toString(), v))
      ..removeWhere((k, v) => k == null || v == null),
  );

  final errorCode = switch (details['readableErrorCode'] as String?) {
    'PURCHASE_CANCELLED' => ErrorCode.cancelled,
    _ => ErrorCode.unknown,
  };

  throw PurchaseFailedException(errorCode);
}