Don't send if headers have already been sent

This commit is contained in:
Sky Young 2018-05-22 14:36:33 -07:00
parent 5522c5649a
commit dda7bacca7
2 changed files with 7 additions and 4 deletions

View File

@ -16,13 +16,16 @@ Common.prototype.notReady = function (err, res, p) {
Common.prototype.handleErrors = function (err, res) {
if (err) {
if (err.code) {
res.status(400).send(err.message + '. Code:' + err.code);
if (!res.headerSent)
res.status(400).send(err.message + '. Code:' + err.code);
} else {
this.log.error(err.stack);
res.status(503).send(err.message);
if (!res.headerSent)
res.status(503).send(err.message);
}
} else {
res.status(404).send('Not found');
if (!res.headerSent)
res.status(404).send('Not found');
}
};

View File

@ -1,7 +1,7 @@
{
"name": "flosight-api",
"description": "A Florincoin blockchain REST and web socket API service for Flocore Node.",
"version": "5.0.0-beta.68",
"version": "5.0.0-beta.69",
"repository": "git://github.com/bitpay/flosight-api.git",
"bugs": {
"url": "https://github.com/bitpay/flosight-api/issues"