[dx] Update error messages for config parsing

ghstack-source-id: 693a3526a73f1fbd25f4e59416f8c65a0f8f1235
Pull Request resolved: https://github.com/facebook/react-forget/pull/2857
This commit is contained in:
Joe Savona
2024-04-17 18:16:32 -07:00
parent 6bf64df538
commit fc7467ac0e
3 changed files with 12 additions and 9 deletions
@@ -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,
@@ -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,
});
@@ -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""`
);
});