Skip to content
Snippets Groups Projects
Commit d227a50d authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Send rpc errors correctly

parent 31ce7296
No related branches found
No related tags found
No related merge requests found
Pipeline #55247 passed
......@@ -175,23 +175,25 @@ export class Peer {
const res = this.bindings[name].apply(this, args);
if (res instanceof Promise) {
res.then(r => {
this.sock.send(encode([1,id,name,r]));
this.sock.send(encode([1,id,null,r]));
});
} else {
this.sock.send(encode([1,id,name,res]));
this.sock.send(encode([1,id,null,res]));
}
} catch(e) {
console.error("Could to dispatch or return call", e);
this.close();
// console.error("Could to dispatch or return call", e);
// this.close();
this.sock.send(encode([1,id,e.toString(),null]));
}
} else if (name in this.proxies) {
//console.log("Proxy for:", name, id);
args.unshift((res: unknown) => {
try {
this.sock.send(encode([1,id,name,res]));
this.sock.send(encode([1,id,null,res]));
} catch(e) {
console.log("ERROR")
this.close();
// console.log("ERROR")
// this.close();
this.sock.send(encode([1,id,e.toString(),null]));
}
});
this.proxies[name].apply(this, args);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment