Skip to content

Commit

Permalink
chore(dev-utils): Update sassdoc to not through uncaught exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Nov 24, 2021
1 parent aa5ecfd commit 8bdf532
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/dev-utils/src/sassdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ function getReferenceLinks(
);

if (!link) {
throw new Error(`Unable to find a reference for ${name} ${type}`);
log.error(`Unable to find a reference for ${name} ${type}`);
process.exit(1);
}

const key = `${name}-${type}`;
Expand Down Expand Up @@ -428,7 +429,10 @@ function getPackageRecord(

const record = lookup[packageName];
if (!record) {
throw new Error();
log.error(
`This should never happen. No PackageSassDocMap for "${packageName}"`
);
process.exit(1);
}

return record;
Expand All @@ -454,9 +458,8 @@ export async function sassdoc(): Promise<void> {
const variable = formatVariableItem(item, references);
const { name } = variable;
if (packageDoc.variables[name]) {
throw new Error(
`${name} already exists in ${packageName}'s variables...`
);
log.error(`${name} already exists in ${packageName}'s variables...`);
process.exit(1);
}

packageDoc.variables[name] = variable;
Expand All @@ -466,9 +469,8 @@ export async function sassdoc(): Promise<void> {
const func = formatFunctionItem(item, references);
const { name } = func;
if (packageDoc.functions[name]) {
throw new Error(
`${name} already exists in ${packageName}'s functions...`
);
log.error(`${name} already exists in ${packageName}'s functions...`);
process.exit(1);
}

packageDoc.functions[name] = func;
Expand All @@ -478,7 +480,8 @@ export async function sassdoc(): Promise<void> {
const mixin = formatMixinItem(item, references);
const { name } = mixin;
if (packageDoc.mixins[name]) {
throw new Error(`${name} already exists in ${packageName}'s mixins...`);
log.error(`${name} already exists in ${packageName}'s mixins...`);
process.exit(1);
}

packageDoc.mixins[name] = mixin;
Expand Down

0 comments on commit 8bdf532

Please sign in to comment.