Skip to content

Commit

Permalink
feat: less verbose module referencing on errors/debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
micalevisk authored Jun 21, 2024
1 parent e31959c commit b0e1a9e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/conditional.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export class ConditionalModule {
options?: { timeout?: number; debug?: boolean },
) {
const { timeout = 5000, debug = true } = options ?? {};
const moduleName = module.name || module.toString();

const timer = setTimeout(() => {
throw new Error(
`Nest was not able to resolve the config variables within ${timeout} milliseconds. Bause of this, the ConditionalModule was not able to determine if ${module.toString()} should be registered or not`,
`Nest was not able to resolve the config variables within ${timeout} milliseconds. Bause of this, the ConditionalModule was not able to determine if ${moduleName} should be registered or not`,
);
}, timeout);
timer.unref();
Expand All @@ -40,7 +41,7 @@ export class ConditionalModule {
} else {
if (debug) {
Logger.debug(
`${condition.toString()} evaluated to false. Skipping the registration of ${module.toString()}`,
`${condition.toString()} evaluated to false. Skipping the registration of ${moduleName}`,
ConditionalModule.name,
);
}
Expand Down

0 comments on commit b0e1a9e

Please sign in to comment.