Skip to content

v2.14.3 — Repo.transaction/1 changeset error handling docs

Choose a tag to compare

@oliver-kriska oliver-kriska released this 20 Jul 06:26
· 65 commits to main since this release
968c4ae

Patch release: document the Repo.transaction/1 changeset error-handling
footgun in the ecto-patterns skill (issue #76, proposed by @ndrean).

Added

  • ecto-patterns: Repo.transaction/1 changeset error handling — new
    reference section (and an anti-pattern row in the auto-loaded SKILL.md) on the
    bare-match footgun inside Repo.transaction(fn -> ... end): {:ok, _} = Repo.update(cs) raises MatchError on an invalid changeset, which rolls back
    and re-raises (crashing the caller, e.g. a 500) — it does not return
    {:error, %MatchError{}}. Documents the explicit case + Repo.rollback/1
    fix (single step) and the with ... else fix (multi-step), and points to
    Repo.transact/1 / Ecto.Multi as the footgun-free forms. Verified
    empirically on Ecto 3.14. Thanks to @ndrean for the proposal (#76).