View Source Bond.InvariantError exception (Bond v1.7.0)

Exception raised when an @invariant for a struct module is violated.

Invariants are checked when a public function in the struct's defining module receives or returns a value of the struct. The error's :function field identifies the function the invariant was checked around; :module is always the struct's module.

Summary

Types

t()

The Bond.InvariantError exception type.

Types

@type t() :: %Bond.InvariantError{
  __exception__: term(),
  binding: keyword(),
  expression: Bond.assertion_expression(),
  file: Path.t(),
  function: {String.t(), non_neg_integer()},
  impl: module() | nil,
  label: Bond.assertion_label(),
  line: integer(),
  module: module(),
  quantifier: map() | nil,
  source_behaviour: module() | nil,
  source_contract: {module(), atom()} | nil,
  source_protocol: module() | nil
}

The Bond.InvariantError exception type.

:source_behaviour is the behaviour module an inherited contract came from (see Bond.Behaviour), or nil for a contract declared directly on the function.

:source_contract is the {module, name} of an applied named contract the failing assertion came from (see defcontract/@apply_contract), or nil otherwise.

:source_protocol is the protocol module a contract was declared on (see Bond.Protocol), or nil; when set, :impl is the implementation module the failing call resolved to (or nil if none could be resolved).

:quantifier carries element-level failure detail when the assertion used forall/exists (see Bond.Predicates), or nil otherwise.