Skip to content

Commit

Permalink
fix: allow the name of Rollup Error to be modified (#5240)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Taegert-Atkinson <[email protected]>
  • Loading branch information
TrickyPi and lukastaegert authored Nov 10, 2023
1 parent ac32f83 commit ef3be44
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
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

0 comments on commit ef3be44

Please sign in to comment.