SnakeBridge.Error (SnakeBridge v0.11.0)

View Source

ML-specific error types for SnakeBridge.

This module provides structured error types that translate Python/ML errors into Elixir exceptions with actionable suggestions.

Available Error Types

Translation

Use SnakeBridge.ErrorTranslator to automatically translate Python exceptions into these structured error types.

Examples

# Creating errors directly
error = SnakeBridge.Error.ShapeMismatchError.new(:matmul,
  shape_a: [3, 4],
  shape_b: [5, 6]
)

# Raising errors
raise SnakeBridge.Error.OutOfMemoryError, device: {:cuda, 0}

# Translating Python errors
translated = SnakeBridge.ErrorTranslator.translate(python_error)

Summary

Functions

dtype_mismatch(expected, got, opts \\ [])

See SnakeBridge.Error.DtypeMismatchError.new/3.

out_of_memory(device, opts \\ [])

See SnakeBridge.Error.OutOfMemoryError.new/2.

shape_mismatch(operation, opts \\ [])

See SnakeBridge.Error.ShapeMismatchError.new/2.