From 79b98764bb2931220501509b268c64e123be2412 Mon Sep 17 00:00:00 2001 From: Stephen Fuhry Date: Thu, 7 Jun 2018 18:49:20 +0000 Subject: [PATCH] Reraise original exception instead of a new one Raising a new KeyError means you lose the original stacktrace, which is going to be more useful since it'll contain more information about the relevant context for this error. --- sqlalchemy_continuum/manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlalchemy_continuum/manager.py b/sqlalchemy_continuum/manager.py index 766780e9..641e9521 100644 --- a/sqlalchemy_continuum/manager.py +++ b/sqlalchemy_continuum/manager.py @@ -32,7 +32,7 @@ def wrapper(self, mapper, connection, target): uow = self.unit_of_work(session) break # The ConnectionFairy is the same, this connection is a clone else: - raise KeyError + raise return func(self, uow, target) return wrapper @@ -400,7 +400,7 @@ def append_association_operation(self, conn, table_name, params, op): uow = self.unit_of_work(conn.session) break # The ConnectionFairy is the same, this connection is a clone else: - raise KeyError + raise uow.pending_statements.append(stmt) def track_cloned_connections(self, c, opt):