fromJson static method

PolarsException fromJson(
  1. Map<String, Object?> json
)

Decodes a native protocol error object into the matching subclass.

Reads the category and message fields. Unknown categories become an InternalPolarsException that preserves the native category name.

Implementation

static PolarsException fromJson(Map<String, Object?> json) {
  final category = json['category'] as String? ?? 'internal';
  final message = json['message'] as String? ?? 'Native protocol error';
  return switch (category) {
    'invalidRequest' => InvalidRequestException(message),
    'unsupported' => UnsupportedPolarsException(message),
    'compute' || 'executionError' => ComputeException(message),
    'io' || 'ioError' => PolarsIoException(message),
    'cancelled' => QueryCancelledException(message),
    'staleHandle' || 'invalidHandle' => StaleHandleException(message),
    'protocolMismatch' ||
    'protocolError' => ProtocolMismatchException(message),
    _ => InternalPolarsException(message, nativeCategory: category),
  };
}