diff --git a/lib/tabula.js b/lib/tabula.js index ccaf13f..a9bebeb 100644 --- a/lib/tabula.js +++ b/lib/tabula.js @@ -208,6 +208,8 @@ function tabulaFormat(items, options) { assert.optionalArrayOfString(options.validFields, 'options.validFields'); assert.optionalBool(options.dottedLookup, 'options.dottedLookup'); assert.optionalBool(options.noAnsi, 'options.noAnsi'); + assert.optionalBool(options.caseInsensitiveLookup, + 'options.caseInsensitiveLookup'); if (!options.columns && items.length === 0) { return ''; @@ -287,7 +289,10 @@ function tabulaFormat(items, options) { if (options.dottedLookup) { try { cell = dottedLookup(o, col.lookup); - } catch (e) {} + } catch (e) { + if (options.caseInsensitiveLookup) + throw e; + } } else { cell = o[col.lookup]; } @@ -403,8 +408,14 @@ function dottedLookup(obj, str, c) { for (var i = 0; i < dots.length; i++) { var dot = dots[i]; s.push(dot); - if (!o.hasOwnProperty(dot)) - throw new Error('no property ' + s.join(c) + ' found'); + if (!o.hasOwnProperty(dot)) { + var msg = 'no property ' + s.join(c) + ' found' + '\n'; + msg += 'The following properties are supported :' + '\n\n'; + Object.keys(o).forEach(function (k) { + msg += k + '\n'; + }); + throw new Error(msg); + } o = o[dot]; } return o;