Skip to content

Commit 2db3a34

Browse files
committed
Implement feedback for error handling on conditional plugins
1 parent d414eda commit 2db3a34

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

v-next/hardhat/src/internal/core/plugins/resolve-plugin-list.ts

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,44 @@ async function reverseTopologicalSort(
8888
}
8989

9090
for (const conditionalDependency of plugin.conditionalDependencies) {
91+
// Check all condition plugins are installed
92+
let conditionModules;
9193
try {
92-
// Check all condition plugins are installed
93-
const conditionModules = await Promise.all(
94+
conditionModules = await Promise.all(
9495
conditionalDependency.condition(),
9596
);
97+
} catch (_error) {
98+
continue;
99+
}
100+
101+
// Check all condition plugins are loaded
102+
if (
103+
conditionModules.some(
104+
(conditionPlugin) =>
105+
!resolvedPlugins.includes(conditionPlugin.default),
106+
)
107+
) {
108+
continue;
109+
}
110+
111+
// Load the conditional dependency
112+
let pluginModule;
113+
try {
114+
pluginModule = await conditionalDependency.plugin();
115+
} catch (error) {
116+
ensureError(error);
117+
await detectPluginNpmDependencyProblems(projectRoot, plugin);
118+
119+
throw new HardhatError(
120+
HardhatError.ERRORS.CORE.PLUGINS.PLUGIN_DEPENDENCY_FAILED_LOAD,
121+
{
122+
pluginId: plugin.id,
123+
},
124+
error,
125+
);
126+
}
96127

97-
// Check all condition plugins are loaded
98-
if (
99-
conditionModules.some(
100-
(conditionPlugin) =>
101-
!resolvedPlugins.includes(conditionPlugin.default),
102-
)
103-
) {
104-
continue;
105-
}
106-
107-
// Load the conditional dependency
108-
const pluginModule = await conditionalDependency.plugin();
109-
110-
await dfs(pluginModule.default);
111-
} catch (_error) {}
128+
await dfs(pluginModule.default);
112129
}
113130
}
114131
}

0 commit comments

Comments
 (0)