Skip to content

Commit

Permalink
fix: improve error handling inside transpiler-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
wessberg committed Sep 7, 2023
1 parent 72ce566 commit c36f7e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/util/transpiler-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function loadModules<TCoreModule extends string, TSubModules extends strin
);
});

if (core.status === "rejected" || rejectedModuleNames.length > 0) {
if (rejectedModuleNames.length > 0) {
const formattedRejectedModuleNames = listFormat(rejectedModuleNames, "and", rejectedModuleName => `"${rejectedModuleName}"`);

throw new ReferenceError(
Expand All @@ -78,6 +78,9 @@ async function loadModules<TCoreModule extends string, TSubModules extends strin
rejectedModuleNames.length === 1 ? "it" : "them"
} if you want to use ${context} for transpilation`
);
} else if (core.status === "rejected") {
if (core.reason instanceof Error) throw core.reason;
else throw new Error(core.reason);
}

// At this point, the core module will always be defined
Expand Down

0 comments on commit c36f7e8

Please sign in to comment.