8000 Better error output · TailorDev/assignees@c440dad · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Better error output
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Jan 27, 2017
1 parent 6c833ea commit c440dad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions bin/assignees
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
const program = require('commander');
const mongoose = require('mongoose');
const chalk = require('chalk');
const util = require('util');

const pkg = require('../package.json');
const inspect = require('../helpers/inspect');

const User = require('../models/User');
const findReviewers = require('../tasks/findReviewers');

Expand Down Expand Up @@ -77,7 +78,7 @@ const listUserFeatures = async (username) => {
return error(`user "${username}" not found`);
}

success(`user "${user.github_login}" has the following features: ${util.inspect(user.features)}`);
success(`user "${user.github_login}" has the following features: ${inspect(user.features)}`);
};

// implements the different commands
Expand Down
3 changes: 3 additions & 0 deletions helpers/inspect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const util = require('util');

module.exports = object => util.inspect(object, { breakLength: Infinity });
11 changes: 6 additions & 5 deletions middlewares/errors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint no-unused-vars: 0 */
const util = require('util');
const logger = require('../helpers/logger');
const inspect = require('../helpers/inspect');

module.exports = (env) => {
if (env === 'test') {
Expand All @@ -12,8 +13,8 @@ module.exports = (env) => {
return (err, req, res, next) => {
const info = [
`request_method=${req.method}`,
`request_body=${util.inspect(req.body)}`,
`request_headers=${util.inspect(req.headers)}`,
`request_body=${inspect(req.body)}`,
`request_headers=${inspect(req.headers)}`,
];

if (req.id) {
Expand All @@ -25,9 +26,9 @@ module.exports = (env) => {
info.push(`user_username=${req.user.github_login}`);
}

info.push(Object.getOwnPropertyNames(err).map 8000 (
k => `${k}=${util.inspect(err[k])}`
));
Object.getOwnPropertyNames(err).forEach(
k => info.push(`error_${k}=${inspect(err[k])}`)
);

logger.error(info.join(' '));

Expand Down
8 changes: 4 additions & 4 deletions tasks/findReviewers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint no-return-assign: 0 */
const util = require('util');
const deck = require('deck');

const inspect = require('../helpers/inspect');
const Repository = require('../models/Repository');
const User = require('../models/User');
const gh = require('../helpers/github');
Expand Down Expand Up @@ -33,8 +33,8 @@ const getFiles = async (github, owner, repo, number) => new Promise((resolve, re

const logPotentialReviewers = (logger, collaborators, authorsFromHistory) => {
logger.info([
`collaborators=${util.inspect(collaborators)}`,
`authors=${util.inspect(authorsFromHistory)}`,
`collaborators=${inspect(collaborators)}`,
`authors=${inspect(authorsFromHistory)}`,
].join(' '));
};

Expand All @@ -44,7 +44,7 @@ const logReviewers = (logger, repository, number, reviewers) => {
`name=${repository.name}`,
`pull_request_number=${number}`,
`max_reviewers=${repository.max_reviewers}`,
`reviewers=${util.inspect(reviewers)}`,
`reviewers=${inspect(reviewers)}`,
].join(' '));
};

Expand Down

0 comments on commit c440dad

Please sign in to comment.
0