Db: throw original exception when rollback fails

This commit is contained in:
Thomas Gelf 2018-09-04 07:41:40 +02:00
parent 6d139752fe
commit 44425d4407

View File

@ -31,6 +31,11 @@ class Db extends DbConnection
return $this->getDbAdapter();
}
/**
* @param $callable
* @return $this
* @throws Exception
*/
public function runFailSafeTransaction($callable)
{
if (! is_callable($callable)) {
@ -43,7 +48,11 @@ class Db extends DbConnection
$callable();
$db->commit();
} catch (Exception $e) {
$db->rollback();
try {
$db->rollback();
} catch (Exception $e) {
// Well... there is nothing we can do here.
}
throw $e;
}