11import * as msg from '../messages' ;
22import { TimedQueue } from '../util/TimedQueue' ;
33import { RpcErrorCodes , RpcError } from './caller/error/RpcError' ;
4- import type { RpcValue } from '../messages/Value' ;
54import { subscribeCompleteObserver } from '../util/subscribeCompleteObserver' ;
5+ import { TypedRpcError } from './caller/error/typed' ;
6+ import type { RpcValue } from '../messages/Value' ;
67import type { RpcCaller } from './caller/RpcCaller' ;
78import type { Call , RpcApiMap } from './caller/types' ;
8- import { TypedRpcError } from './caller/error/typed' ;
99
1010type Send = ( messages : ( msg . ReactiveRpcServerMessage | msg . NotificationMessage ) [ ] ) => void ;
1111
@@ -182,12 +182,12 @@ export class RpcMessageStreamProcessor<Ctx = unknown> {
182182 let call = this . activeStreamCalls . get ( id ) ;
183183 if ( ! call ) {
184184 if ( ! method ) {
185- this . sendError ( id , RpcErrorCodes . NO_METHOD_SPECIFIED ) ;
185+ this . sendError ( id , RpcErrorCodes . METHOD_INV ) ;
186186 return ;
187187 }
188188 const info = this . caller . info ( method ) ;
189189 if ( ! info ) {
190- this . sendError ( id , RpcErrorCodes . METHOD_NOT_FOUND ) ;
190+ this . sendError ( id , RpcErrorCodes . METHOD_UNK ) ;
191191 return ;
192192 }
193193 if ( info . isStreaming ) {
@@ -216,12 +216,12 @@ export class RpcMessageStreamProcessor<Ctx = unknown> {
216216 return ;
217217 }
218218 if ( ! method ) {
219- this . sendError ( id , RpcErrorCodes . NO_METHOD_SPECIFIED ) ;
219+ this . sendError ( id , RpcErrorCodes . METHOD_INV ) ;
220220 return ;
221221 }
222222 const caller = this . caller ;
223223 if ( ! caller . exists ( method ) ) {
224- this . sendError ( id , RpcErrorCodes . METHOD_NOT_FOUND ) ;
224+ this . sendError ( id , RpcErrorCodes . METHOD_UNK ) ;
225225 return ;
226226 }
227227 const { isStreaming} = caller . info ( method ) ;
@@ -245,16 +245,16 @@ export class RpcMessageStreamProcessor<Ctx = unknown> {
245245 return ;
246246 }
247247 if ( ! method ) {
248- this . sendError ( id , RpcErrorCodes . NO_METHOD_SPECIFIED ) ;
248+ this . sendError ( id , RpcErrorCodes . METHOD_INV ) ;
249249 return ;
250250 }
251251 if ( ! this . caller . exists ( method ) ) {
252- this . sendError ( id , RpcErrorCodes . METHOD_NOT_FOUND ) ;
252+ this . sendError ( id , RpcErrorCodes . METHOD_UNK ) ;
253253 return ;
254254 }
255255 const { isStreaming} = this . caller . info ( method ) ;
256256 if ( ! isStreaming ) {
257- void this . sendError ( id , RpcErrorCodes . INVALID_METHOD ) ;
257+ void this . sendError ( id , RpcErrorCodes . METHOD_UNK ) ;
258258 return ;
259259 }
260260 const streamCall = this . createStreamCall ( id , method , ctx ) ;
@@ -272,7 +272,7 @@ export class RpcMessageStreamProcessor<Ctx = unknown> {
272272
273273 public onNotificationMessage ( message : msg . NotificationMessage , ctx : Ctx ) : void {
274274 const { method, value} = message ;
275- if ( ! method || method . length > 128 ) throw RpcError . fromCode ( RpcErrorCodes . INVALID_METHOD ) ;
275+ if ( ! method || method . length > 128 ) throw RpcError . fromErrno ( RpcErrorCodes . METHOD_INV ) ;
276276 const request = value && typeof value === 'object' ? value ?. data : undefined ;
277277 this . caller . notification ( method , request , ctx ) . catch ( ( ) => { } ) ;
278278 }
0 commit comments