Skip to content

Commit ee06565

Browse files
committed
Improve error message when sandbox connection is already in transaction
1 parent 84fe263 commit ee06565

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

lib/ecto/adapters/sql/sandbox.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,15 @@ defmodule Ecto.Adapters.SQL.Sandbox do
591591
{:ok, _, conn_state} ->
592592
{:ok, Connection, {conn_mod, conn_state, false}}
593593

594+
{:transaction, _conn_state} ->
595+
raise """
596+
Ecto SQL sandbox transaction cannot be started because there is already\
597+
a transaction running.
598+
599+
This either means some code is starting a transaction before the sandbox\
600+
or a connection was not appropriately rolled back after use.
601+
"""
602+
594603
{_error_or_disconnect, err, conn_state} ->
595604
{:disconnect, err, conn_mod, conn_state}
596605
end

0 commit comments

Comments
 (0)