rpc: add RPCError.

This commit is contained in:
Christopher Jeffrey 2016-08-05 15:07:04 -07:00
parent 3406a09cd5
commit 4a398517d9
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 170 additions and 144 deletions

File diff suppressed because it is too large Load Diff

View File

@ -333,7 +333,16 @@ HTTPServer.prototype._init = function _init() {
self.rpc.execute(req.body, function(err, json) {
if (err) {
self.logger.error(err);
return send(400, {
if (err.type === 'RPCError') {
return send(400, {
result: err.message,
error: null,
id: req.body.id
});
}
return send(500, {
result: null,
error: {
message: err.message,
@ -342,6 +351,7 @@ HTTPServer.prototype._init = function _init() {
id: req.body.id
});
}
send(200, {
result: json,
error: null,