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

Translates Python/ML errors into structured SnakeBridge errors.

This module recognizes common ML error patterns from PyTorch, NumPy,
and other ML libraries, and translates them into structured error
types with actionable suggestions.

## Supported Error Types

- `SnakeBridge.Error.ShapeMismatchError` - Tensor shape incompatibilities
- `SnakeBridge.Error.OutOfMemoryError` - GPU/CPU memory exhaustion
- `SnakeBridge.Error.DtypeMismatchError` - Tensor dtype incompatibilities

## Examples

    iex> error = %RuntimeError{message: "CUDA out of memory"}
    iex> SnakeBridge.ErrorTranslator.translate(error)
    %SnakeBridge.Error.OutOfMemoryError{device: {:cuda, 0}, ...}

# `dtype_from_string`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/error_translator.ex#L153)

```elixir
@spec dtype_from_string(String.t()) :: atom()
```

Converts a Python/PyTorch dtype string to an Elixir atom.

## Examples

    iex> SnakeBridge.ErrorTranslator.dtype_from_string("Float")
    :float32

    iex> SnakeBridge.ErrorTranslator.dtype_from_string("torch.float64")
    :float64

# `translate`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/error_translator.ex#L58)

```elixir
@spec translate(Exception.t() | map() | nil, String.t() | nil) :: Exception.t() | nil
```

Translates a Python/ML error to a structured SnakeBridge error.

Returns the original error if it cannot be translated.

# `translate_message`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/error_translator.ex#L93)

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

Translates an error message string to a structured error.

Returns nil if the message cannot be translated.

---

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