You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was peeking at pixie code and stumbled on transaction code.
I think it should re-throw caught exceptions.
That's very important in order to do a decent error handling at most applications.
publicfunctiontransaction(\Closure$callback)
{
try {
// Begin the PDO transaction$this->pdo->beginTransaction();
// Get the Transaction class$transaction = $this->container->build('\\Pixie\\QueryBuilder\\Transaction', array($this->connection));
// Call closure$callback($transaction);
// If no errors have been thrown or the transaction wasn't completed within// the closure, commit the changes$this->pdo->commit();
return$this;
} catch (TransactionHaltException$e) {
// Commit or rollback behavior has been handled in the closure, so exitreturn$this;
} catch (\Exception$e) {
// something happened, rollback changes$this->pdo->rollBack();
// CHANGE THIS// return $this;// FOR THATthrow$e;
}
}
The text was updated successfully, but these errors were encountered:
I agree, rolling back is not handling Exception and it should be rethrown so other code could handle it.
Alternative solution is to handle Exceptions inside the closure. If Exception occurs, rollback, handle it and throw TransactionHaltException to signal that transaction is already finished.
Hi everyone!
I was peeking at pixie code and stumbled on transaction code.
I think it should re-throw caught exceptions.
That's very important in order to do a decent error handling at most applications.
The text was updated successfully, but these errors were encountered: