# `SnakeBridge.SerializationError`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/serialization_error.ex#L1)

Raised when attempting to encode a value that cannot be serialized for Python.

SnakeBridge supports encoding:
- Primitives: `nil`, booleans, integers, floats, strings
- Collections: lists, maps, tuples, MapSets
- Special types: atoms, DateTime, Date, Time, SnakeBridge.Bytes
- References: SnakeBridge.Ref, SnakeBridge.StreamRef
- Functions: anonymous functions (as callbacks)
- Special floats: `:infinity`, `:neg_infinity`, `:nan`

Types that cannot be serialized:
- PIDs, ports, references
- Custom structs without serialization support
- File handles, sockets, other system resources

## Resolution

For unsupported types, you have several options:

1. **Create a Python object and pass the ref**:

       {:ok, ref} = SnakeBridge.call("module", "create_object", [...])
       SnakeBridge.call("module", "use_object", [ref])

2. **Convert to a supported type**:

       # Instead of passing a PID
       SnakeBridge.call("module", "fn", [inspect(pid)])
       # Or extract relevant data
       SnakeBridge.call("module", "fn", [pid_to_list(pid)])

3. **Use explicit bytes for binary data**:

       SnakeBridge.call("module", "fn", [SnakeBridge.bytes(binary)])

# `t`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/serialization_error.ex#L42)

```elixir
@type t() :: %SnakeBridge.SerializationError{
  __exception__: true,
  message: String.t(),
  type: atom() | module(),
  value: term()
}
```

# `new`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/serialization_error.ex#L67)

```elixir
@spec new(String.t() | nil) :: t()
```

Creates a SerializationError from a message string.

This is used for error messages from the Python side.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
