Slack messaging #169

Merged
bones7242 merged 11 commits from slack-messaging into master 2017-09-21 21:11:32 +02:00
4 changed files with 20 additions and 9 deletions
Showing only changes of commit f53ca8d958 - Show all commits

View file

@ -1,9 +1,20 @@
const logger = require('winston');
const { postToStats } = require('../controllers/statsController.js');
function useObjectPropertiesIfNoKeys (err) {
if (Object.keys(err).length === 0) {
let newErrorObject = {};
Object.getOwnPropertyNames(err).forEach((key) => {
kauffj commented 2017-09-16 00:18:31 +02:00 (Migrated from github.com)
Review

When is there a non-enumerable property being passed that this is required?

When is there a non-enumerable property being passed that this is required?
bones7242 commented 2017-09-21 21:10:37 +02:00 (Migrated from github.com)
Review

for errors created by node (e.g. new Error('error message')) the stack and message are non-enumerable

for errors created by node (e.g. `new Error('error message')`) the stack and message are non-enumerable
newErrorObject[key] = err[key];
});
return newErrorObject;
}
return err;
}
module.exports = {
handleRequestError (action, originalUrl, ip, error, res) {
logger.error('Request Error:', error.message);
logger.error('Request Error:', useObjectPropertiesIfNoKeys(error));
postToStats(action, originalUrl, ip, null, null, error);
if (error.response) {
res.status(error.response.status).send(error.response.data.error.message);
@ -16,7 +27,7 @@ module.exports = {
}
},
handlePublishError (error) {
logger.error('Publish Error:', error.message);
logger.error('Publish Error:', useObjectPropertiesIfNoKeys(error));
if (error.code === 'ECONNREFUSED') {
return 'Connection refused. The daemon may not be running.';
} else if (error.response.data.error) {

View file

@ -115,7 +115,7 @@ module.exports = {
}
})
.catch(error => {
logger.error('Lbrynet Error:', error.message);
logger.error('Lbrynet Error:', error);
resolve('/home/lbry/Downloads/');
});
});

View file

@ -52,7 +52,7 @@ function getLongClaimIdFromShortClaimId (name, shortId) {
.then(result => {
switch (result.length) {
case 0:
return reject(new Error('That is an invalid Short Claim Id'));
throw new Error('That is an invalid Short Claim Id');
default: // note results must be sorted
return resolve(result[0].claimId);
}
@ -179,7 +179,7 @@ db['getShortClaimIdFromLongClaimId'] = (claimId, claimName) => {
.then(result => {
switch (result.length) {
case 0:
return reject(new Error('That is an invalid claim name'));
throw new Error('That is an invalid claim name');
default:
return resolve(sortResult(result, claimId));
}
@ -198,7 +198,7 @@ db['getShortChannelIdFromLongChannelId'] = (channelName, longChannelId) => {
.then(result => {
switch (result.length) {
case 0:
return reject(new Error('That is an invalid channel name'));
throw new Error('That is an invalid channel name');
default:
return resolve(sortResult(result, longChannelId));
}
@ -238,7 +238,7 @@ db['resolveClaim'] = (name, claimId) => {
case 1:
return resolve(result[0]);
default:
return new Error('more than one entry matches that name and claimID');
throw new Error('more than one entry matches that name and claimID');
}
})
.catch(error => {
@ -255,7 +255,7 @@ db['getClaimIdByLongChannelId'] = (channelId, claimName) => {
.then(result => {
switch (result.length) {
case 0:
return reject(new Error('There is no such claim for that channel'));
throw new Error('There is no such claim for that channel');
default:
return resolve(result[0].claimId);
}

View file

@ -40,7 +40,7 @@
"socketio-file-upload": "^0.6.0",
"universal-analytics": "^0.4.13",
"winston": "^2.3.1",
"winston-slack-webhook": "^0.1.5"
"winston-slack-webhook": "billbitt/winston-slack-webhook"
},
kauffj commented 2017-09-16 00:19:43 +02:00 (Migrated from github.com)
Review

should this be billbitt?

should this be billbitt?
bones7242 commented 2017-09-21 21:11:27 +02:00 (Migrated from github.com)
Review

I made my own fork to fix an issue with the package, and submitted a PR to the main package. The PR was accepted, so will update this to point to main package in next update.

I made my own fork to fix an issue with the package, and submitted a PR to the main package. The PR was accepted, so will update this to point to main package in next update.
"devDependencies": {
"eslint": "3.19.0",