Merge pull request #9716 from sarthakNITT/#9548
fix: improve error messages for invalid rule files
This commit is contained in:
commit
f14a2ff90a
1 changed files with 22 additions and 1 deletions
|
|
@ -258,9 +258,30 @@ export async function configYamlToContinueConfig(options: {
|
|||
continueConfig.slashCommands?.push(slashCommand);
|
||||
}
|
||||
} catch (e) {
|
||||
// If the file is in a rules directory, we can provide a more helpful error message
|
||||
// because we know it's likely a rule definition
|
||||
const isRuleFile =
|
||||
file.path.toLowerCase().includes("/rules/") ||
|
||||
file.path.toLowerCase().includes("\\rules\\");
|
||||
|
||||
let message = `Failed to convert prompt file ${file.path} to slash command: ${e instanceof Error ? e.message : e}`;
|
||||
|
||||
if (isRuleFile) {
|
||||
const isYamlError =
|
||||
e instanceof Error &&
|
||||
(e.name?.includes("YAML") || e.message.includes("flow sequence"));
|
||||
|
||||
const prefix = isYamlError
|
||||
? "Failed to parse rule definition"
|
||||
: "Failed to process rule definition";
|
||||
|
||||
const errorDetails = e instanceof Error ? e.message : String(e);
|
||||
message = `${prefix} ${file.path}: ${errorDetails}`;
|
||||
}
|
||||
|
||||
localErrors.push({
|
||||
fatal: false,
|
||||
message: `Failed to convert prompt file ${file.path} to slash command: ${e instanceof Error ? e.message : e}`,
|
||||
message,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue