From 187ea1c739e7f49b295f99ed56de84898567cddb Mon Sep 17 00:00:00 2001 From: Cole Gleason Date: Wed, 22 Jan 2014 00:50:14 -0600 Subject: [PATCH] chore(VersionError): add debug code to emails showing completed ops This adds a field to the email if there is an error on batchUpdate. This field contains all the attempted operations. So the last item in the list would be the operation that we encountered the error at. @lefnire, mind taking a look at this and pushing if you feel comfortable with adding more to the emails? --- src/controllers/user.js | 2 ++ src/utils.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/user.js b/src/controllers/user.js index 7263766615..b806130d2e 100644 --- a/src/controllers/user.js +++ b/src/controllers/user.js @@ -437,10 +437,12 @@ api.batchUpdate = function(req, res, next) { api[_req.op](_req, res); }; + res.locals.ops = []; // Setup the array of functions we're going to call in parallel with async var ops = _.transform(req.body, function(result, _req) { if (!_.isEmpty(_req)) { result.push(function(cb) { + res.locals.ops.push(_req); callOp(_req, cb); }); } diff --git a/src/utils.js b/src/utils.js index 0fb599fde9..791ba3c57c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -66,7 +66,8 @@ module.exports.errorHandler = function(err, req, res, next) { "\n\noriginalUrl: " + req.originalUrl + "\n\nauth: " + req.headers['x-api-user'] + ' | ' + req.headers['x-api-key'] + "\n\nheaders: " + JSON.stringify(req.headers) + - "\n\nbody: " + JSON.stringify(req.body); + "\n\nbody: " + JSON.stringify(req.body) + + (res.locals.ops ? "\n\ncompleted ops: " + JSON.stringify(res.locals.ops) : ""); module.exports.sendEmail({ from: "HabitRPG <" + nconf.get('SMTP_USER') + ">", to: nconf.get('ADMIN_EMAIL') || nconf.get('SMTP_USER'),