Skip to content

Commit ef3be44

Browse files
fix: allow the name of Rollup Error to be modified (#5240)
Co-authored-by: Lukas Taegert-Atkinson <[email protected]>
1 parent ac32f83 commit ef3be44

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

src/utils/logs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
export function error(base: Error | RollupLog): never {
3636
if (!(base instanceof Error)) {
3737
base = Object.assign(new Error(base.message), base);
38-
Object.defineProperty(base, 'name', { value: 'RollupError' });
38+
Object.defineProperty(base, 'name', { value: 'RollupError', writable: true });
3939
}
4040
throw base;
4141
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { assertIncludes } = require('../../../utils.js');
2+
3+
module.exports = defineTest({
4+
description: 'handles uncaught errors under watch',
5+
command: 'rollup --config rollup.config.js -w',
6+
error: () => true,
7+
stderr(stderr) {
8+
assertIncludes(stderr, 'Uncaught RollupError: LOL');
9+
}
10+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
assert.equal( 42, 42 );
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
input: 'main.js',
3+
output: {
4+
format: 'es'
5+
},
6+
plugins: [
7+
{
8+
name: 'test',
9+
buildStart() {
10+
Promise.resolve().then(() => {
11+
this.error('LOL');
12+
});
13+
}
14+
}
15+
]
16+
};

test/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export interface TestConfigCli extends TestConfigBase {
109109
* Test the expected error. Assertions about the test output will only
110110
* be performed afterward if you return "true" or do not supply this option.
111111
*/
112-
error?: (error: RollupError) => boolean | void;
112+
error?: (error: Error) => boolean | void;
113113
/**
114114
* Execute the bundled code.
115115
*/

0 commit comments

Comments
 (0)