Skip to content

Commit 9e9b54d

Browse files
authored
[compiler] Make CompilerError compatible with reflection (#32539)
1 parent 029e8bd commit 9e9b54d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export class CompilerError extends Error {
188188
constructor(...args: Array<any>) {
189189
super(...args);
190190
this.name = 'ReactCompilerError';
191+
this.details = [];
191192
}
192193

193194
override get message(): string {
@@ -197,7 +198,10 @@ export class CompilerError extends Error {
197198
override set message(_message: string) {}
198199

199200
override toString(): string {
200-
return this.details.map(detail => detail.toString()).join('\n\n');
201+
if (Array.isArray(this.details)) {
202+
return this.details.map(detail => detail.toString()).join('\n\n');
203+
}
204+
return this.name;
201205
}
202206

203207
push(options: CompilerErrorDetailOptions): CompilerErrorDetail {

0 commit comments

Comments
 (0)