Skip to content

Commit

Permalink
feat(validation): Validate error names
Browse files Browse the repository at this point in the history
  • Loading branch information
Blckbrry-Pi committed Mar 6, 2024
1 parent 908506a commit 99aa92c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/project/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ export async function loadModule(
);
}

// Verify error names
const errorIssues = new Map<string, NameError>();
for (const errorName in config.errors) {
const issue = validateIdentifier(errorName, "error", NameType.Errors);
if (issue) {
errorIssues.set(errorName, issue);
}
}

if (errorIssues.size > 0) {
throw NameError.fromSubErrors([...errorIssues.values()], "error", name);
}

// Load db config
let db: ModuleDatabase | undefined = undefined;
if (await exists(join(modulePath, "db"), { isDirectory: true })) {
Expand Down

0 comments on commit 99aa92c

Please sign in to comment.