不要怂,就是干,撸起袖子干!

Commit 613401a5 by overlookmotel

Refactor for readability

1 parent a915f859
Showing with 11 additions and 12 deletions
......@@ -979,19 +979,18 @@ class Sequelize {
if (!autoCallback) return transaction.prepareEnvironment().return(transaction);
// autoCallback provided
return Sequelize._clsRun(() =>
transaction.prepareEnvironment().then(() =>
autoCallback(transaction)
).tap(() =>
transaction.commit()
).catch(err =>
// Rollback transaction if not already finished (commit, rollback, etc) and reject with original error
Promise.try(() => {
// Rollback (ignore any error in rollback)
return Sequelize._clsRun(() => {
return transaction.prepareEnvironment()
.then(() => autoCallback(transaction))
.tap(() => transaction.commit())
.catch(err => {
// Rollback transaction if not already finished (commit, rollback, etc)
// and reject with original error (ignore any error in rollback)
return Promise.try(() => {
if (!transaction.finished) return transaction.rollback().catch(function() {});
}).throw(err)
)
);
}).throw(err);
});
});
}
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!