Skip to content
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

fix: allow the name of Rollup Error to be modified #5240

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
export function error(base: Error | RollupLog): never {
if (!(base instanceof Error)) {
base = Object.assign(new Error(base.message), base);
Object.defineProperty(base, 'name', { value: 'RollupError' });
Object.defineProperty(base, 'name', { value: 'RollupError', writable: true });
}
throw base;
}
Expand Down
10 changes: 10 additions & 0 deletions test/cli/samples/handles-uncaught-errors-under-watch/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { assertIncludes } = require('../../../utils.js');

module.exports = defineTest({
description: 'handles uncaught errors under watch',
command: 'rollup --config rollup.config.js -w',
error: () => true,
stderr(stderr) {
assertIncludes(stderr, 'Uncaught RollupError: LOL');
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assert.equal( 42, 42 );
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
input: 'main.js',
output: {
format: 'es'
},
plugins: [
{
name: 'test',
buildStart() {
Promise.resolve().then(() => {
this.error('LOL');
});
}
}
]
};
2 changes: 1 addition & 1 deletion test/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export interface TestConfigCli extends TestConfigBase {
* Test the expected error. Assertions about the test output will only
* be performed afterward if you return "true" or do not supply this option.
*/
error?: (error: RollupError) => boolean | void;
error?: (error: Error) => boolean | void;
/**
* Execute the bundled code.
*/
Expand Down