DuckdbEx.Exceptions (DuckdbEx v0.2.0)

View Source

Exception types for DuckDB Elixir.

This module defines all exception types that can be raised by DuckDB operations. The exception hierarchy mirrors the Python duckdb client for API compatibility.

Reference: duckdb-python/duckdb/init.py

Exception Hierarchy

The exceptions follow the DB-API 2.0 specification with DuckDB-specific extensions:

  • Error (base exception)
    • DatabaseError
      • DataError
      • OperationalError
      • IntegrityError
      • InternalError
      • ProgrammingError
      • NotSupportedError
    • DuckDB-specific exceptions
      • BinderException
      • CatalogException
      • ConnectionException
      • ConstraintException
      • ConversionException
      • DependencyException
      • FatalException
      • HTTPException
      • InternalException
      • InterruptException
      • InvalidInputException
      • InvalidTypeException
      • IOException
      • NotImplementedException
      • OutOfMemoryException
      • OutOfRangeException
      • ParserException
      • PermissionException
      • SequenceException
      • SerializationException
      • SyntaxException
      • TransactionException
      • TypeMismatchException
  • Warning (base warning)

Summary

Functions

Maps an error string from the NIF to the appropriate exception.

Functions

from_error_string(error_string)

@spec from_error_string(String.t()) :: struct()

Maps an error string from the NIF to the appropriate exception.

The NIF layer returns errors as strings in the format "ExceptionType:message". This function parses that format and returns the appropriate exception struct.

Examples

iex> DuckdbEx.Exceptions.from_error_string("BinderException:Column 'foo' not found")
%DuckdbEx.Exceptions.BinderException{message: "Column 'foo' not found"}

iex> DuckdbEx.Exceptions.from_error_string("CatalogException:Table 'users' not found")
%DuckdbEx.Exceptions.CatalogException{message: "Table 'users' not found"}

Reference: Python exception mapping in duckdb-python