@samitouri / QOS-React / commits / 9e9b54d7f6

[compiler] Make CompilerError compatible with reflection (#32539)

lauren committed Mar 6, 2025 at 13:06 UTC 9e9b54d7f6c67b452c969abb98f4f7637ed72f56
1 file changed +5 -1
compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts
+5 -1
@@ -188,6 +188,7 @@ export class CompilerError extends Error {
188 constructor(...args: Array<any>) {
189 super(...args);
190 this.name = 'ReactCompilerError';
191 + this.details = [];
192 }
193
194 override get message(): string {
@@ -197,7 +198,10 @@ export class CompilerError extends Error {
198 override set message(_message: string) {}
199
200 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;
205 }
206
207 push(options: CompilerErrorDetailOptions): CompilerErrorDetail {