diff --git a/routes/dms.js b/routes/dms.js index 60371d7e..f0e09859 100644 --- a/routes/dms.js +++ b/routes/dms.js @@ -194,11 +194,13 @@ module.exports = function () { // Prep text views - load first 10Kb of a file to 'content' attribut which // we can render as is in the template. datapackage.displayResources = await Promise.all(datapackage.displayResources.map(async item => { - await Promise.all(item.resource.views.map(async (view, index) => { - if (view && view.specType === 'text' && item.resource.path) { - item.resource.views[index].content = await fetchTextContent(item.resource.path) - } - })) + if (item.resource.views) { + await Promise.all(item.resource.views.map(async (view, index) => { + if (view && view.specType === 'text' && item.resource.path) { + item.resource.views[index].content = await fetchTextContent(item.resource.path) + } + })) + } return item })) diff --git a/utils/logger.js b/utils/logger.js index 9da2c94a..6f421509 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -2,13 +2,14 @@ const winston = require('winston') const config = require('../config/index') const customFormat = winston.format.printf((info) => { - const { level, message, ...meta } = info - return `${meta.timestamp} [${level}] ${message}` + const { level, message, stack, ...meta } = info + return `${meta.timestamp} [${level}] ${message}${stack ? '\n' + stack : ''}` }) const logger = winston.createLogger({ level: config.get('LOG_LEVEL') || 'info', format: winston.format.combine( + winston.format.errors({ stack: true }), winston.format.json(), winston.format.timestamp(), winston.format.colorize(),