Skip to content

Commit

Permalink
Merge pull request #12905 from micalevisk/feat/verbose-unknown-module…
Browse files Browse the repository at this point in the history
…-errormsg

feat(core): display module's name on `.select(module)` errors
  • Loading branch information
kamilmysliwiec authored Dec 18, 2023
2 parents 91cedae + 204971c commit a1780ff
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
18 changes: 9 additions & 9 deletions packages/common/decorators/core/controller.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ export function Controller(
)
? [defaultPath, undefined, undefined, undefined]
: isString(prefixOrOptions) || Array.isArray(prefixOrOptions)
? [prefixOrOptions, undefined, undefined, undefined]
: [
prefixOrOptions.path || defaultPath,
prefixOrOptions.host,
{ scope: prefixOrOptions.scope, durable: prefixOrOptions.durable },
Array.isArray(prefixOrOptions.version)
? Array.from(new Set(prefixOrOptions.version))
: prefixOrOptions.version,
];
? [prefixOrOptions, undefined, undefined, undefined]
: [
prefixOrOptions.path || defaultPath,
prefixOrOptions.host,
{ scope: prefixOrOptions.scope, durable: prefixOrOptions.durable },
Array.isArray(prefixOrOptions.version)
? Array.from(new Set(prefixOrOptions.version))
: prefixOrOptions.version,
];

return (target: object) => {
Reflect.defineMetadata(CONTROLLER_WATERMARK, true, target);
Expand Down
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
4 changes: 2 additions & 2 deletions packages/core/nest-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ export class NestFactoryStatic {
return result instanceof Promise
? result.then(mapToProxy)
: result instanceof NestApplication
? proxy
: result;
? proxy
: result;
};

if (!(prop in receiver) && prop in adapter) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/router/router-response-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export class RouterResponseController {
result && result.statusCode
? result.statusCode
: redirectResponse.statusCode
? redirectResponse.statusCode
: HttpStatus.FOUND;
? redirectResponse.statusCode
: HttpStatus.FOUND;
const url = result && result.url ? result.url : redirectResponse.url;
this.applicationRef.redirect(response, statusCode, url);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/microservices/server/server-rmq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ export class ServerRMQ extends Server implements CustomTransportStrategy {
(msg: Record<string, any>) => this.handleMessage(msg, channel),
{
noAck: this.noAck,
consumerTag: this.getOptionsProp(this.options, 'consumerTag', undefined)
consumerTag: this.getOptionsProp(
this.options,
'consumerTag',
undefined,
),
},
);
callback();
Expand Down
4 changes: 2 additions & 2 deletions packages/platform-socket.io/adapters/io-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export class IoAdapter extends AbstractWsAdapter {
return server && isFunction(server.of)
? server.of(namespace)
: namespace
? this.createIOServer(port, opt).of(namespace)
: this.createIOServer(port, opt);
? this.createIOServer(port, opt).of(namespace)
: this.createIOServer(port, opt);
}

public createIOServer(port: number, options?: any): any {
Expand Down

0 comments on commit a1780ff

Please sign in to comment.