http: catch rpc errors.

This commit is contained in:
Christopher Jeffrey 2016-08-17 04:58:35 -07:00
parent 197e9f7aa9
commit d0c4ea008b
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -391,7 +391,7 @@ HTTPServer.prototype._init = function _init() {
self.rpc = new RPC(self.node);
}
self.rpc.execute(req.body, function(err, json) {
function handle(err, json) {
if (err) {
self.logger.error(err);
@ -418,7 +418,13 @@ HTTPServer.prototype._init = function _init() {
error: null,
id: req.body.id
});
});
}
try {
self.rpc.execute(req.body, handle);
} catch (e) {
handle(e);
}
});
this.get('/', function(req, res, next, send) {