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 incompatibilitiesSnakeBridge.Error.OutOfMemoryError- GPU/CPU memory exhaustionSnakeBridge.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}, ...}
Summary
Functions
Converts a Python/PyTorch dtype string to an Elixir atom.
Translates a Python/ML error to a structured SnakeBridge error.
Translates an error message string to a structured error.
Functions
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
@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.
@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.