Handling Errors with try-catch-finally
What critical pattern is demonstrated here?
let transaction;
try {
transaction = await db.begin();
await performOperations();
await transaction.commit();
} catch (error) {
if (transaction) {
await transaction.rollback();
}
throw error;
}