add message to ErrorResponse

This commit is contained in:
2019-09-21 21:27:14 +02:00
parent 26504a34e7
commit a0611d2de3
21 changed files with 6608 additions and 8 deletions
+1 -4
View File
@@ -18,7 +18,6 @@ export class RPCServer<
private errorHandler: T.ErrorHandler
private connectionHandler: T.ConnectionHandler
constructor(
private port:number,
private exporters: I.Exporter<SubResType>[] = [],
@@ -52,7 +51,6 @@ export class RPCServer<
\n<------------OFFENDING RPC:
\n`+badRPC.toString()+`
\n>------------OFFENDING RPC`)
this.startWebsocket()
}
@@ -61,7 +59,7 @@ export class RPCServer<
this.io.attach(this.ws)
this.io.on('socket', (socket:I.Socket) => {
socket.on('error', (err) => this.errorHandler(socket, err))
socket.on('close', ()=> this.closeHandler(socket))
socket.on('close', () => this.closeHandler(socket))
this.connectionHandler(socket)
this.initRPCs(socket)
})
@@ -74,7 +72,6 @@ export class RPCServer<
protected initRPCs(socket:I.Socket){
socket.hook('info', () => rpcInfos)
const rpcInfos:T.ExtendedRpcInfo[] = [
...this.exporters.flatMap(exporter => U.rpcHooker(socket, exporter))
]
+1 -1
View File
@@ -21,7 +21,7 @@ export type Outcome = "Success" | "Error"
export type Respose<T> = T & { result: Outcome }
export type SuccessResponse<T = {}> = Respose<T> & { result: "Success" }
export type ErrorResponse<T = {}> = Respose<T> & { result: "Error" }
export type ErrorResponse<T = {}> = Respose<T> & { result: "Error", message?:string }
export type SubscriptionResponse<T = {}> = Respose<T> & { result: "Success"; uuid: string }
export type RPCType = 'Hook' | 'Unhook' | 'Call'
+1
View File
@@ -4,6 +4,7 @@ import * as T from "./Types";
import * as I from "./Interfaces";
import { SubscriptionResponse } from "./Types";
export const rpcToRpcinfo = <SubResT = {}>(rpc : T.RPC<SubResT>, owner: T.Owner):T.RpcInfo => {
switch (typeof rpc){
case "object":