Skip to content

Commit

Permalink
feat(core): display module's name on .select(module) errors
Browse files Browse the repository at this point in the history
  • Loading branch information
micalevisk committed Dec 13, 2023
1 parent 1e489c7 commit 6bb08b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/core/errors/exceptions/unknown-module.exception.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { RuntimeException } from './runtime.exception';

export class UnknownModuleException extends RuntimeException {
constructor() {
constructor(moduleName?: string) {
super(
'Nest could not select the given module (it does not exist in current context)',
`Nest could not select the given module (${
moduleName ? `"${moduleName}"` : 'it'
} does not exist in current context).`,
);
}
}
2 changes: 1 addition & 1 deletion packages/core/nest-application-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class NestApplicationContext<

const selectedModule = modulesContainer.get(token);
if (!selectedModule) {
throw new UnknownModuleException();
throw new UnknownModuleException(type.name);
}
return new NestApplicationContext(
this.container,
Expand Down

0 comments on commit 6bb08b4

Please sign in to comment.