Skip to content

Commit 73ff3d1

Browse files
remove exceptions
1 parent 13ac2a9 commit 73ff3d1

1 file changed

Lines changed: 0 additions & 17 deletions

File tree

packages/core/helpers/execution-context-host.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import {
66
RpcArgumentsHost,
77
WsArgumentsHost,
88
} from '@nestjs/common/interfaces/features/arguments-host.interface';
9-
import { RuntimeException } from '../errors/exceptions/runtime.exception';
10-
import { INVALID_EXECUTION_CONTEXT } from './messages';
119

1210
export class ExecutionContextHost<TContext extends ContextType = ContextType>
1311
implements ExecutionContext<TContext> {
@@ -44,22 +42,12 @@ export class ExecutionContextHost<TContext extends ContextType = ContextType>
4442
}
4543

4644
switchToRpc(): RpcArgumentsHost {
47-
if (this.contextType !== 'rpc') {
48-
throw new RuntimeException(
49-
INVALID_EXECUTION_CONTEXT(this.contextType, 'switchToRpc()'),
50-
);
51-
}
5245
return Object.assign(this, {
5346
getData: () => this.getArgByIndex(0),
5447
});
5548
}
5649

5750
switchToHttp(): HttpArgumentsHost {
58-
if (this.contextType !== 'http') {
59-
throw new RuntimeException(
60-
INVALID_EXECUTION_CONTEXT(this.contextType, 'switchToHttp()'),
61-
);
62-
}
6351
return Object.assign(this, {
6452
getRequest: () => this.getArgByIndex(0),
6553
getResponse: () => this.getArgByIndex(1),
@@ -68,11 +56,6 @@ export class ExecutionContextHost<TContext extends ContextType = ContextType>
6856
}
6957

7058
switchToWs(): WsArgumentsHost {
71-
if (this.contextType !== 'ws') {
72-
throw new RuntimeException(
73-
INVALID_EXECUTION_CONTEXT(this.contextType, 'switchToWs()'),
74-
);
75-
}
7659
return Object.assign(this, {
7760
getClient: () => this.getArgByIndex(0),
7861
getData: () => this.getArgByIndex(1),

0 commit comments

Comments
 (0)