Skip to content

Commit d8a39a7

Browse files
committed
bugfix(): fix usage of ExternalContextCreator in NextApplicationContext (when NestContainer.applicationConfig is undefined)
1 parent 845c5df commit d8a39a7

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/core/exceptions/external-exception-filter-context.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ExternalExceptionsHandler } from './external-exceptions-handler';
1111
export class ExternalExceptionFilterContext extends BaseExceptionFilterContext {
1212
constructor(
1313
container: NestContainer,
14-
private readonly config: ApplicationConfig,
14+
private readonly config?: ApplicationConfig,
1515
) {
1616
super(container);
1717
}
@@ -41,6 +41,9 @@ export class ExternalExceptionFilterContext extends BaseExceptionFilterContext {
4141
}
4242

4343
public getGlobalMetadata<T extends any[]>(): T {
44+
if (!this.config) {
45+
return [] as T;
46+
}
4447
return this.config.getGlobalFilters() as T;
4548
}
4649
}

packages/core/test/helpers/external-context-creator.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ describe('ExternalContextCreator', () => {
4343
new PipesContextCreator(new NestContainer()),
4444
consumer,
4545
new ExternalExceptionFilterContext(
46-
new NestContainer(),
47-
new ApplicationConfig(),
46+
new NestContainer()
4847
),
4948
);
5049
});

0 commit comments

Comments
 (0)