-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error printing for Hardhat v3 #5455
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
@@ -0,0 +1,2 @@ | |||
export const HARDHAT_NAME = "Hardhat"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be merged with v-next/hardhat/src/internal/cli/init/constants.ts
v-next/hardhat/src/cli.ts
Outdated
|
||
main(process.argv.slice(2)).catch((error: unknown) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
printErrorMessages(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather do this in main
, so that that contains all the logic of the cli, and this file is just a bootstrap.
Also, process.exit()
shouldn't be used, as it kills the process before giving it the opportunity to flush any i/o buffer (e.g. printing the error messages)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a0b79ac
print: (message: string) => void = console.error, | ||
): void { | ||
const showStackTraces = | ||
process.argv.includes("--show-stack-traces") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd pass this from main
, so that we keep everything argv parsing there. It's a bit unexpected here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 8111de5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just left a few comments
Errors are formatted and printed based on their category. Errors may belong to one of these categories:
1. Hardhat errors: these are thrown from
core
orhardhat
packages.2. Hardhat plugin errors: these are thrown from official Hardhat plugins, such as
hardhat-ignition
. Technically, this category would also include built-in plugins likerun
, but since we’re not adding thepluginId
property to their descriptors, they fall into category 1 (Hardhat errors).3. Hardhat community plugin errors: these are thrown from community-developed plugins that use the
HardhatPluginError
, such ashardhat-deploy
.4. Other errors: this category includes any other errors that don't fall into the above categories. This includes instances of
Error
, as well as objects or strings.Doc: https://www.notion.so/nomicfoundation/Design-doc-for-error-messages-2d49562c43de497d8241d8b024fe83b2#851e84f778c04437a5953c5f98a0b6d6
Screenshots:
(ignore the Time to run the task.. messages)
Hardhat errors:

Hardhat plugin errors (added

pluginId
to therun
descriptor, as we don't have any):Hardhat community plugin errors:

Other errors (


Error
instance andobject
):