0

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:

  1. 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?
Bass
  • 1
  • 2
  • So the question about "preferred approach" might bring some opinionated answers, which is generally discouraged here on SO. Same goes for looking for sources where to find developers, tutorials, etc - again, just not on topic here, sorry... Even though my main expertise is Solidity, and this is more of a JavaScript topic, I'm going to close this question as a duplicate of another question that already contains answers focused on handling exceptions thrown in Promises. Based on the linked post, the first approach seems more efficient and safe. – Petr Hejda Oct 24 '22 at 15:46

0 Answers0