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
1210export 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