Skip to content
Permalink
Browse files

columns: enrich error message when provided as literal object

  • Loading branch information...
wdavidw committed Mar 11, 2019
1 parent 4175932 commit 7ee298f630bd70a9344c0d2d34391bf5f99c578f
Showing with 4 additions and 3 deletions.
  1. +1 −0 CHANGELOG.md
  2. +1 −1 lib/es5/index.js
  3. +1 −1 lib/index.js
  4. +1 −1 test/option.columns.coffee
@@ -9,6 +9,7 @@

## Trunk

* columns: enrich error message when provided as literal object
* cast: handle undefined columns
* skip_lines_with_error: new sample

@@ -1166,7 +1166,7 @@ var normalizeColumnsArray = function normalizeColumnsArray(columns) {
};
} else if (isObject(column)) {
if (typeof column.name !== 'string') {
throw new Error("Invalid Option columns: property \"name\" is required at position ".concat(i));
throw new Error("Invalid Option columns: property \"name\" is required at position ".concat(i, " when column is an object literal"));
}

normalizedColumns[i] = column;
@@ -892,7 +892,7 @@ const normalizeColumnsArray = function(columns){
normalizedColumns[i] = { name: column }
}else if(isObject(column)){
if(typeof column.name !== 'string'){
throw new Error(`Invalid Option columns: property "name" is required at position ${i}`)
throw new Error(`Invalid Option columns: property "name" is required at position ${i} when column is an object literal`)
}
normalizedColumns[i] = column
}else{
@@ -12,7 +12,7 @@ describe 'Option `columns`', ->
},{
invalid: 'oh no'
}], (->)
).should.throw 'Invalid Option columns: property "name" is required at position 1'
).should.throw 'Invalid Option columns: property "name" is required at position 1 when column is an object literal'

it 'check the columns value', ->
(->

0 comments on commit 7ee298f

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.