Skip to content

Commit

Permalink
Merge cb7b9e2 into 1714b51
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunnerLivio committed Feb 16, 2019
2 parents 1714b51 + cb7b9e2 commit 9f3ff2f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Module } from '../../injector/module';

export class UnknownDependenciesException extends RuntimeException {
constructor(
type: string,
type: string | symbol,
unknownDependencyContext: InjectorDependencyContext,
module?: Module,
) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/errors/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ const getModuleName = (module: Module) =>
(module && getInstanceName(module.metatype)) || 'current';

export const UNKNOWN_DEPENDENCIES_MESSAGE = (
type: string,
type: string | symbol,
unknownDependencyContext: InjectorDependencyContext,
module: Module,
) => {
const { index, dependencies, key } = unknownDependencyContext;
let message = `Nest can't resolve dependencies of the ${type}`;
let message = `Nest can't resolve dependencies of the ${type.toString()}`;

if (isNil(index)) {
message += `. Please make sure that the "${key}" property is available in the current context.`;
Expand Down
5 changes: 5 additions & 0 deletions packages/core/test/errors/test/messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ describe('UnknownDependenciesMessage', () => {
myModule.metatype = myMetaType;
expect(new UnknownDependenciesException('CatService', { index, dependencies: ['', 'MY_TOKEN'] }, myModule as Module).message).to.equal(expectedResult);
});
it('should display the symbol name of the provider', () => {
const expectedResult = 'Nest can\'t resolve dependencies of the Symbol(CatProvider) (?). ' +
'Please make sure that the argument at index [0] is available in the current context.';
expect(new UnknownDependenciesException(Symbol('CatProvider'), { index, dependencies: [''] }).message).to.equal(expectedResult);
});
});

0 comments on commit 9f3ff2f

Please sign in to comment.