Skip to content

Commit 4a9201e

Browse files
authored
chore: enhance error logs of loading coverage plugin failed (#573)
1 parent 2509d68 commit 4a9201e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/core/src/coverage/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createRequire } from 'node:module';
22
import { pathToFileURL } from 'node:url';
33
import type { RsbuildPlugin } from '@rsbuild/core';
44
import type { CoverageOptions, CoverageProvider } from '../types/coverage';
5+
import { color } from '../utils';
56
export const CoverageProviderMap: Record<string, string> = {
67
istanbul: '@rstest/coverage-istanbul',
78
};
@@ -31,10 +32,12 @@ export const loadCoverageProvider = async (
3132
pluginCoverage,
3233
CoverageProvider,
3334
};
34-
} catch (error) {
35-
throw new Error(
36-
`Failed to load coverage provider module: ${moduleName} in ${root}. Make sure it is installed.\nOriginal error: ${(error as Error).message}`,
35+
} catch {
36+
const error = new Error(
37+
`Failed to load coverage provider module: ${color.cyan(moduleName)} in ${color.underline(root)}, please make sure it is installed.\n`,
3738
);
39+
error.stack = '';
40+
throw error;
3841
}
3942
};
4043

0 commit comments

Comments
 (0)