-
Notifications
You must be signed in to change notification settings - Fork 28
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
Centralize error descriptions (PR 1) #479
Conversation
One open question for this PR is whether or not we want to add an |
207b1d9
to
298c9f5
Compare
Okay I added these and a new question has popped up: should our |
@@ -0,0 +1,322 @@ | |||
export const ERROR_PREFIX = "IGN"; |
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.
Most of this file is basically copied structurally from the similar files in Hardhat.
number: number; | ||
// Message can use templates. See applyErrorMessageTemplate | ||
message: string; | ||
} |
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 think Hardhat has extra fields here, but I figured we start with the minimum and can always add more later.
* | ||
* @alpha | ||
*/ | ||
export class IgnitionError extends Error { | ||
export class CustomError extends 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.
Hardhat does a lot of clever stuff to modify the displayed output of errors inside this class. We currently aren't doing those things, but I wanted to leave room for us to add it later if we decide to.
*/ | ||
export class IgnitionValidationError extends IgnitionError { |
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 removed the validation specific error in favor of a validation category in errors-list.ts
. All errors thrown in Ignition core are now IgnitionError
s
* | ||
* @alpha | ||
*/ | ||
export class NomicIgnitionPluginError extends IgnitionPluginError { |
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 added this and the above IgnitionPluginError
again mimicking the similar classes from Hardhat.
* | ||
* @alpha | ||
*/ | ||
export class UnsupportedOperationError extends IgnitionError { |
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 error was only being used in one place, so I removed it as well and added the message for it to errors-list.ts
export class UnsupportedOperationError extends IgnitionError { | ||
constructor(message: string) { | ||
super(message); | ||
export function applyErrorMessageTemplate( |
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.
copy/pasted from Hardhat
packages/core/src/errors.ts
Outdated
super(message); | ||
this.pluginName = pluginName; | ||
Object.setPrototypeOf(this, IgnitionPluginError.prototype); |
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.
Can we leave the comment that was here before? also, new.target
is dynamic, so it works with extensions to this tupe.
errors-list.ts
, mimicking the similar structure in hardhatIgnitionError
to require one of the newErrorDescriptor
types as an input, rather than a raw stringIgnitionValidationError
as a class since its stack capturing is no longer functioning as originally intendedIgnitionValidationError
intoIgnitionError
fixes #418