@nomicfoundation/hardhat-errors 3.0.0-next.2 → 3.0.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/descriptors.d.ts +1860 -1203
- package/dist/src/descriptors.d.ts.map +1 -1
- package/dist/src/descriptors.js +2247 -1280
- package/dist/src/descriptors.js.map +1 -1
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +10 -3
- package/dist/src/errors.js.map +1 -1
- package/package.json +8 -14
- package/src/descriptors.ts +2431 -1403
- package/src/errors.ts +13 -3
package/src/errors.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ErrorDescriptor } from "./descriptors.js";
|
|
|
3
3
|
import { CustomError } from "@nomicfoundation/hardhat-utils/error";
|
|
4
4
|
import { isObject } from "@nomicfoundation/hardhat-utils/lang";
|
|
5
5
|
|
|
6
|
-
import { ERRORS } from "./descriptors.js";
|
|
6
|
+
import { ERRORS, ERROR_CATEGORIES } from "./descriptors.js";
|
|
7
7
|
|
|
8
8
|
export type ErrorMessageTemplateValue =
|
|
9
9
|
| string
|
|
@@ -154,7 +154,17 @@ export class HardhatError<
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
public get pluginId(): string | undefined {
|
|
157
|
-
|
|
157
|
+
for (const category of Object.values(ERROR_CATEGORIES)) {
|
|
158
|
+
const isWithinCategoryRange =
|
|
159
|
+
this.#descriptor.number >= category.min &&
|
|
160
|
+
this.#descriptor.number <= category.max;
|
|
161
|
+
|
|
162
|
+
if (isWithinCategoryRange) {
|
|
163
|
+
return category.pluginId;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return undefined;
|
|
158
168
|
}
|
|
159
169
|
|
|
160
170
|
public get descriptor(): ErrorDescriptor {
|
|
@@ -224,7 +234,7 @@ export function assertHardhatInvariant(
|
|
|
224
234
|
message: string,
|
|
225
235
|
): asserts invariant {
|
|
226
236
|
if (!invariant) {
|
|
227
|
-
throw new HardhatError(ERRORS.INTERNAL.ASSERTION_ERROR, { message });
|
|
237
|
+
throw new HardhatError(ERRORS.CORE.INTERNAL.ASSERTION_ERROR, { message });
|
|
228
238
|
}
|
|
229
239
|
}
|
|
230
240
|
|