EctoLibSql.Error exception (EctoLibSql v0.8.8)

Copy Markdown View Source

Exception raised when a LibSQL database operation fails.

This exception contains detailed error information from the underlying LibSQL/SQLite database, including constraint violation details.

Fields

  • :message - Human-readable error message
  • :sqlite - Map containing SQLite-specific error details (:code, :message)

Summary

Functions

Extracts the constraint field name from an error message.

Checks if the error is a constraint violation.

Types

t()

@type t() :: %EctoLibSql.Error{
  __exception__: true,
  message: String.t(),
  sqlite: %{code: atom(), message: String.t()}
}

Functions

constraint_name(error)

Extracts the constraint field name from an error message.

Returns the field name if a constraint violation pattern is found, nil otherwise.

Examples

iex> error = %EctoLibSql.Error{message: "constraint failed: users.email"}
iex> EctoLibSql.Error.constraint_name(error)
"email"

constraint_violation?(error)

Checks if the error is a constraint violation.

Returns true if the error message indicates a constraint failure, false otherwise.

Examples

iex> error = %EctoLibSql.Error{message: "constraint failed: users.email"}
iex> EctoLibSql.Error.constraint_violation?(error)
true