Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.

Commit f714b89

Browse files
committed
fix: update error message with invalid columns type
1 parent 9e3b65d commit f714b89

File tree

6 files changed

+9
-5
lines changed

6 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Please join and contribute:
1717
* relax_column_count: rename INCONSISTENT_RECORD_LENGTH to RECORD_INCONSISTENT_FIELDS_LENGTH (easy)
1818
* relax_column_count: rename RECORD_DONT_MATCH_COLUMNS_LENGTH to RECORD_INCONSISTENT_COLUMNS (easy)
1919

20+
## Trunk
21+
22+
* fix: update error message with invalid column type
23+
2024
## Version 4.15.4
2125

2226
* fix: handle cast value 0 fix #315

lib/browser/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ var Parser = /*#__PURE__*/function (_Transform) {
285285
} else if (options.columns === undefined || options.columns === null || options.columns === false) {
286286
options.columns = false;
287287
} else {
288-
throw new CsvError('CSV_INVALID_OPTION_COLUMNS', ['Invalid option columns:', 'expect an object, a function or true,', "got ".concat(JSON.stringify(options.columns))], options);
288+
throw new CsvError('CSV_INVALID_OPTION_COLUMNS', ['Invalid option columns:', 'expect an array, a function or true,', "got ".concat(JSON.stringify(options.columns))], options);
289289
} // Normalize option `columns_duplicates_to_array`
290290

291291

lib/browser/sync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ var Parser = /*#__PURE__*/function (_Transform) {
285285
} else if (options.columns === undefined || options.columns === null || options.columns === false) {
286286
options.columns = false;
287287
} else {
288-
throw new CsvError('CSV_INVALID_OPTION_COLUMNS', ['Invalid option columns:', 'expect an object, a function or true,', "got ".concat(JSON.stringify(options.columns))], options);
288+
throw new CsvError('CSV_INVALID_OPTION_COLUMNS', ['Invalid option columns:', 'expect an array, a function or true,', "got ".concat(JSON.stringify(options.columns))], options);
289289
} // Normalize option `columns_duplicates_to_array`
290290

291291

lib/es5/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ var Parser = /*#__PURE__*/function (_Transform) {
177177
} else if (options.columns === undefined || options.columns === null || options.columns === false) {
178178
options.columns = false;
179179
} else {
180-
throw new CsvError('CSV_INVALID_OPTION_COLUMNS', ['Invalid option columns:', 'expect an object, a function or true,', "got ".concat(JSON.stringify(options.columns))], options);
180+
throw new CsvError('CSV_INVALID_OPTION_COLUMNS', ['Invalid option columns:', 'expect an array, a function or true,', "got ".concat(JSON.stringify(options.columns))], options);
181181
} // Normalize option `columns_duplicates_to_array`
182182

183183

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class Parser extends Transform {
107107
}else{
108108
throw new CsvError('CSV_INVALID_OPTION_COLUMNS', [
109109
'Invalid option columns:',
110-
'expect an object, a function or true,',
110+
'expect an array, a function or true,',
111111
`got ${JSON.stringify(options.columns)}`
112112
], options)
113113
}

test/option.columns.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe 'Option `columns`', ->
2828
(->
2929
parse "", columns: {}, (->)
3030
).should.throw
31-
message: 'Invalid option columns: expect an object, a function or true, got {}'
31+
message: 'Invalid option columns: expect an array, a function or true, got {}'
3232
code: 'CSV_INVALID_OPTION_COLUMNS'
3333

3434
it 'skip columns with false value', (next) ->

0 commit comments

Comments
 (0)