Blame view
node_modules/strong-error-handler/lib/logger.js
739 Bytes
f7563de62
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
// Copyright IBM Corp. 2016. All Rights Reserved. // Node module: strong-error-handler // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT 'use strict'; var format = require('util').format; var g = require('strong-globalize')(); module.exports = function logToConsole(req, err) { if (!Array.isArray(err)) { g.error('Unhandled error for request %s %s: %s', req.method, req.url, err.stack || err); return; } var errMsg = g.f('Unhandled array of errors for request %s %s ', req.method, req.url); var errors = err.map(formatError).join(' '); console.error(errMsg, errors); }; function formatError(err) { return format('%s', err.stack || err); } |