Drops.Relation.Plugins.Queryable.InvalidQueryError exception (drops_relation v0.1.0)

View Source

Exception raised when a queryable operation contains validation errors.

This exception is raised when query compilers detect invalid operations such as comparing nil values to non-nullable fields, using undefined associations in preloads, or other validation failures.

Examples

# Raised when trying to compare nil to a non-nullable field
raise InvalidQueryError, errors: ["name is not nullable, comparing to `nil` is not allowed"]

# Raised when trying to preload a non-defined association
raise InvalidQueryError, errors: ["association :invalid_assoc is not defined"]

Summary

Functions

Returns a human-readable error message for the exception.

Creates a new InvalidQueryError with the given errors.

Types

t()

@type t() :: %Drops.Relation.Plugins.Queryable.InvalidQueryError{
  __exception__: true,
  errors: [String.t()]
}

Functions

message(invalid_query_error)

Returns a human-readable error message for the exception.

Examples

iex> error = InvalidQueryError.new(["name is not nullable", "invalid association"])
iex> InvalidQueryError.message(error)
"Query validation failed:\n  - name is not nullable\n  - invalid association"

new(errors)

@spec new([String.t()]) :: t()

Creates a new InvalidQueryError with the given errors.

Parameters

  • errors - A list of human-readable error messages

Examples

iex> InvalidQueryError.new(["field is not nullable"])
%InvalidQueryError{errors: ["field is not nullable"]}