Skip to content

Commit 7b0b083

Browse files
chenjiahanCopilot
andauthored
fix: improve error handling when loading addons failed (#6631)
Co-authored-by: Copilot <[email protected]>
1 parent f944375 commit 7b0b083

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/core/src/plugins/nodeAddons.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ export const pluginNodeAddons = (): RsbuildPlugin => ({
2626

2727
return `
2828
try {
29-
const path = require("node:path");
30-
process.dlopen(module, path.join(__dirname, "${name}"));
29+
const path = require("node:path");
30+
process.dlopen(module, path.join(__dirname, "${name}"));
3131
} catch (error) {
32-
throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
32+
throw new Error('Failed to load Node.js addon: "${name}"', {
33+
cause: error,
34+
});
3335
}
3436
`;
3537
},

0 commit comments

Comments
 (0)