Fix transmitting errors through IPC

This commit is contained in:
Schuyler Cebulskie
2016-09-27 02:40:29 -04:00
parent 9d3b7b49dd
commit 38366f627d
4 changed files with 13 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ const EventEmitter = require('events').EventEmitter;
const Shard = require('./Shard');
const Collection = require('../util/Collection');
const makePlainError = require('../util/MakePlainError');
/**
* This is a utility class that can be used to help you spawn shards of your Client. Each shard is completely separate
@@ -58,11 +59,11 @@ class ShardingManager extends EventEmitter {
if (message._sFetchProp) {
this.fetchClientValues(message._sFetchProp)
.then(results => shard.send({ _sFetchProp: message._sFetchProp, _result: results }))
.catch(err => shard.send({ _sFetchProp: message._sFetchProp, _error: err }));
.catch(err => shard.send({ _sFetchProp: message._sFetchProp, _error: makePlainError(err) }));
} else if (message._sEval) {
this.broadcastEval(message._sEval)
.then(results => shard.send({ _sEval: message._sEval, _result: results }))
.catch(err => shard.send({ _sEval: message._sEval, _error: err }));
.catch(err => shard.send({ _sEval: message._sEval, _error: makePlainError(err) }));
}
});
}