Skip to content

Commit

Permalink
simplify error catching
Browse files Browse the repository at this point in the history
  • Loading branch information
seleniumforest committed Sep 16, 2022
1 parent 77735c1 commit b1724b8
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { decodeTxRaw } = require("@cosmjs/proto-signing");
const { co } = require("co");
const config = require("../config.json");
const { saveProcessedTx, getLastProcessedTxs, dbReady, createEmptyBlock } = require("./db");
const { getLastProcessedTxs, dbReady, createEmptyBlock } = require("./db");
const msgHandlers = require("./messages");
const { getTxsInBlock, getNewHeight } = require("./requests");
const { registerNetwork } = require("./endpoints");
Expand All @@ -20,13 +20,10 @@ const processNewTx = async (network, newtx) => {
let msgLog = newtx?.log?.find(x => i === 0 ? !x.msg_index : x.msg_index === i);
let handler = msgHandlers[msg.typeUrl];

return (async () => {
try {
return handler(network, msg, newtx, msgLog)
} catch (err) {
console.error(`Error handling tx in ${network.name} msg ${err?.message}`)
}
})();
return handler(network, msg, newtx, msgLog)
.catch((err) => {
console.error(`Error handling txid ${newtx.hash} in ${network.name} msg ${err?.message}`)
});
});

await Promise.all(handlers);
Expand Down

0 comments on commit b1724b8

Please sign in to comment.