diff --git a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts index 41542c327f..321db2fd10 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts @@ -299,7 +299,8 @@ export function compileProgram( */ if (environment.isErr()) { CompilerError.throwInvalidConfig({ - reason: "Error in validating environment config", + reason: + "Error in validating environment config. This is an advanced setting and not meant to be used directly", description: environment.unwrapErr().toString(), suggestions: null, loc: null, diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts index 57d8fe73b0..6ada70c488 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts @@ -393,9 +393,9 @@ export function parseConfigPragma(pragma: string): EnvironmentConfig { if (config.success) { return config.data; } - CompilerError.throwInvalidConfig({ - reason: `${fromZodError(config.error)}`, - description: "Update Forget config to fix the error", + CompilerError.invariant(false, { + reason: "Internal error, could not parse config from pragma string", + description: `${fromZodError(config.error)}`, loc: null, suggestions: null, }); @@ -597,8 +597,9 @@ export function validateEnvironmentConfig( } CompilerError.throwInvalidConfig({ - reason: `${fromZodError(config.error)}`, - description: "Update Forget config to fix the error", + reason: + "Could not validate environment config. Update React Compiler config to fix the error", + description: `${fromZodError(config.error)}`, loc: null, suggestions: null, }); @@ -615,8 +616,9 @@ export function tryParseExternalFunction( } CompilerError.throwInvalidConfig({ - reason: `${fromZodError(externalFunction.error)}`, - description: "Update Forget config to fix the error", + reason: + "Could not parse external function. Update React Compiler config to fix the error", + description: `${fromZodError(externalFunction.error)}`, loc: null, suggestions: null, }); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/envConfig-test.ts b/compiler/packages/babel-plugin-react-forget/src/__tests__/envConfig-test.ts index 2975d33872..78467393b3 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/envConfig-test.ts +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/envConfig-test.ts @@ -20,7 +20,7 @@ describe("parseConfigPragma()", () => { validateHooksUsage: 1, } as any); }).toThrowErrorMatchingInlineSnapshot( - `"InvalidConfig: Validation error: Expected boolean, received number at "validateHooksUsage". Update Forget config to fix the error"` + `"InvalidConfig: Could not validate environment config. Update React Compiler config to fix the error. Validation error: Expected boolean, received number at "validateHooksUsage""` ); });