Merge pull request #20 from strongloop/globalize
Globalize strong-error-handler
This commit is contained in:
commit
ad4e5728d4
|
@ -31,3 +31,7 @@ node_modules
|
||||||
|
|
||||||
# Optional REPL history
|
# Optional REPL history
|
||||||
.node_repl_history
|
.node_repl_history
|
||||||
|
|
||||||
|
# globalization
|
||||||
|
intl/*
|
||||||
|
!intl/en/
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"85312d2b987e2e44001db3d6963a1364": "Unhandled array of errors for request {0} {1}\n",
|
||||||
|
"adcbd4c562b19f45fb5d3427619646d5": "Unhandled error for request {0} {1}: {2}"
|
||||||
|
}
|
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
|
var SG = require('strong-globalize');
|
||||||
|
SG.SetRootDir(path.resolve(__dirname, '..'));
|
||||||
var buildResponseData = require('./data-builder');
|
var buildResponseData = require('./data-builder');
|
||||||
var debug = require('debug')('strong-error-handler');
|
var debug = require('debug')('strong-error-handler');
|
||||||
var format = require('util').format;
|
var format = require('util').format;
|
||||||
|
|
|
@ -6,17 +6,19 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var format = require('util').format;
|
var format = require('util').format;
|
||||||
|
var g = require('strong-globalize')();
|
||||||
|
|
||||||
module.exports = function logToConsole(req, err) {
|
module.exports = function logToConsole(req, err) {
|
||||||
if (!Array.isArray(err)) {
|
if (!Array.isArray(err)) {
|
||||||
console.error('Unhandled error for request %s %s: %s',
|
g.error('Unhandled error for request %s %s: %s',
|
||||||
req.method, req.url, err.stack || err);
|
req.method, req.url, err.stack || err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errMsg = g.f('Unhandled array of errors for request %s %s\n',
|
||||||
|
req.method, req.url);
|
||||||
var errors = err.map(formatError).join('\n');
|
var errors = err.map(formatError).join('\n');
|
||||||
console.error('Unhandled array of errors for request %s %s\n',
|
console.error(errMsg, errors);
|
||||||
req.method, req.url, errors);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function formatError(err) {
|
function formatError(err) {
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
"accepts": "^1.3.3",
|
"accepts": "^1.3.3",
|
||||||
"debug": "^2.2.0",
|
"debug": "^2.2.0",
|
||||||
"ejs": "^2.4.2",
|
"ejs": "^2.4.2",
|
||||||
"http-status": "^0.2.2"
|
"http-status": "^0.2.2",
|
||||||
|
"strong-globalize": "^2.6.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^2.1.1",
|
"chai": "^2.1.1",
|
||||||
|
|
Loading…
Reference in New Issue