I have a very important question to ask the Lords of SO today. Before I dive into the thick of this conundrum I present a simple question on error handling methods for (EVM) smart contract deployment followed by a much more pressing inquiry.
I'm currently working on a smart contract using Solidity/Hardhat and was told to use a new pattern for my main function within my deploy.js file. "Allegedly" (eye roll) the standard main function that I've been using to handle errors is not as good as my colleagues. I see no difference but I will let the Overlords decide:
OG MAIN PATTERN
const runMain = async () => {
try {
await main();
process.exit(0);
} catch (error) {
console.log(error);
process.exit(1);
}
NEW & IMPROVED(?)
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
When my co-worker noticed the pattern I was using at the bottom of my deploy.js file, he smugly stated "that main function ain't it, chief."
I responded by saying that "there's no reason for me to switch my OG error handler for some new pattern."
He responded by saying that "there's a clear difference and now it makes sense why you don't have a girlfriend."
So to summarize my questions:
- Why would his method be preferred over mine? Should I part ways with my trusty pattern? 2. More importantly, where do I find the blockchain baddies?