From 9a8adbee885fb209492b7f1ae0364470e3db4619 Mon Sep 17 00:00:00 2001 From: ntibi Date: Fri, 29 Apr 2022 12:48:10 +0200 Subject: [PATCH] feat(core): enhance circular dependency error message --- packages/core/injector/container.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/injector/container.ts b/packages/core/injector/container.ts index b50957d384d..138524a5c9c 100644 --- a/packages/core/injector/container.ts +++ b/packages/core/injector/container.ts @@ -154,13 +154,13 @@ export class NestContainer { provider: Provider, token: string, ): string | symbol | Function { + const moduleRef = this.modules.get(token); if (!provider) { - throw new CircularDependencyException(); + throw new CircularDependencyException(moduleRef?.metatype.name); } - if (!this.modules.has(token)) { + if (!moduleRef) { throw new UnknownModuleException(); } - const moduleRef = this.modules.get(token); return moduleRef.addProvider(provider); }