Transaction.on.error

trans.on("error", function () {
    // Do stuff when transaction fails
});