Merge branch 'issuer-rewrite' into ajs-update

This commit is contained in:
aj 2017-10-23 23:18:47 +00:00
commit 7f653e4d7a
2 changed files with 12 additions and 16 deletions

View File

@ -149,9 +149,10 @@ module.exports.create = function () {
process.on('unhandledRejection', function (err) { process.on('unhandledRejection', function (err) {
// this should always throw // this should always throw
// (it means somewhere we're not using bluebird by accident) // (it means somewhere we're not using bluebird by accident)
console.error('[caught] [unhandledRejection]'); console.error('[caught unhandledRejection]:', err.message || '');
console.error(Object.keys(err)); Object.keys(err).forEach(function (key) {
console.error(err); console.log('\t'+key+': '+err[key]);
});
console.error(err.stack); console.error(err.stack);
}); });
process.on('rejectionHandled', function (msg) { process.on('rejectionHandled', function (msg) {

View File

@ -1,20 +1,21 @@
'use strict'; 'use strict';
module.exports.rejectableRequest = function rejectableRequest(req, res, promise, msg) { function rejectableRequest(req, res, promise, msg) {
return promise.error(function (err) { return promise.error(function (err) {
res.error(err); res.error(err);
}).catch(function (err) { }).catch(function (err) {
console.error('[ERROR] \'' + msg + '\''); console.error('[ERROR] \'' + msg + '\'');
console.error(err.message); // The stack contains the message as well, so no need to log the message when we log the stack
console.error(err.stack); console.error(err.stack || err.message || JSON.stringify(err));
res.error(err); res.error(err);
}); });
}; }
module.exports.rejectableRequest = rejectableRequest;
module.exports.promisableRequest = module.exports.promisableRequest =
module.exports.promiseRequest = function promiseRequest(req, res, promise, msg) { module.exports.promiseRequest = function promiseRequest(req, res, promise, msg) {
return promise.then(function (result) { promise = promise.then(function (result) {
if (result._cache) { if (result._cache) {
res.setHeader('Cache-Control', 'public, max-age=' + (result._cache / 1000)); res.setHeader('Cache-Control', 'public, max-age=' + (result._cache / 1000));
res.setHeader('Expires', new Date(Date.now() + result._cache).toUTCString()); res.setHeader('Expires', new Date(Date.now() + result._cache).toUTCString());
@ -26,13 +27,7 @@ module.exports.promiseRequest = function promiseRequest(req, res, promise, msg)
result = result._value; result = result._value;
} }
res.send(result); res.send(result);
}).error(function (err) {
res.error(err);
}).catch(function (err) {
console.error('[ERROR] \'' + msg + '\'');
console.error(err.message);
console.error(err.stack);
res.error(err);
}); });
return rejectableRequest(req, res, promise, msg);
}; };