Snakepit.Error.Parser (Snakepit v0.8.7)
View SourceParses Python exception data into structured Elixir errors.
Automatically detects error patterns (OOM, shape mismatch, device errors) and creates appropriate structured exceptions.
Summary
Functions
Extracts a shape from a string representation.
Parses a gRPC error response into a structured error.
Parses error data into a structured error.
Functions
Extracts a shape from a string representation.
Examples
iex> Parser.extract_shape("[3, 224, 224]")
[3, 224, 224]
iex> Parser.extract_shape("(10, 20)")
[10, 20]
@spec from_grpc_error(map()) :: {:ok, Exception.t()} | {:error, :invalid_input}
Parses a gRPC error response into a structured error.
@spec parse(map() | term()) :: {:ok, Exception.t()} | {:error, :invalid_input}
Parses error data into a structured error.
Accepts a map with "type", "message", and optionally "traceback".
Examples
{:ok, error} = Parser.parse(%{
"type" => "ValueError",
"message" => "Invalid input"
})