From 36397800a9b479658e6497bb521a27c037fc3abb Mon Sep 17 00:00:00 2001 From: David Worms Date: Mon, 28 Nov 2022 10:39:27 +0100 Subject: [PATCH] fix(csv-parse): improve INVALID_OPENING_QUOTE error message (fix adaltas/node-csv-docs#120) --- packages/csv-parse/dist/cjs/index.cjs | 11 +++++++---- packages/csv-parse/dist/cjs/sync.cjs | 11 +++++++---- packages/csv-parse/dist/esm/index.js | 11 +++++++---- packages/csv-parse/dist/esm/sync.js | 11 +++++++---- packages/csv-parse/dist/iife/index.js | 11 +++++++---- packages/csv-parse/dist/iife/sync.js | 11 +++++++---- packages/csv-parse/dist/umd/index.js | 11 +++++++---- packages/csv-parse/dist/umd/sync.js | 11 +++++++---- packages/csv-parse/lib/api/CsvError.js | 2 +- packages/csv-parse/lib/api/index.js | 9 ++++++--- packages/csv-parse/test/api.events.coffee | 2 +- packages/csv-parse/test/info.lines.coffee | 4 ++-- packages/csv-parse/test/option.bom.coffee | 2 +- packages/csv-parse/test/option.ltrim.coffee | 2 +- packages/csv-parse/test/option.quote.coffee | 17 +++++++++++++++-- .../csv-parse/test/option.relax_quotes.coffee | 4 ++-- .../test/option.skip_records_with_error.coffee | 4 ++-- 17 files changed, 87 insertions(+), 47 deletions(-) diff --git a/packages/csv-parse/dist/cjs/index.cjs b/packages/csv-parse/dist/cjs/index.cjs index c943b4d7f..d55b0a352 100644 --- a/packages/csv-parse/dist/cjs/index.cjs +++ b/packages/csv-parse/dist/cjs/index.cjs @@ -8,7 +8,7 @@ const is_object = function(obj){ class CsvError extends Error { constructor(code, message, options, ...contexts) { - if(Array.isArray(message)) message = message.join(' '); + if(Array.isArray(message)) message = message.join(' ').trim(); super(message); if(Error.captureStackTrace !== undefined){ Error.captureStackTrace(this, CsvError); @@ -639,7 +639,7 @@ const transform = function(original_options = {}) { }, // Central parser implementation parse: function(nextBuf, end, push, close){ - const {bom, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; + const {bom, encoding, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; let {comment, escape, quote, record_delimiter} = this.options; const {bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this.state; let buf; @@ -775,11 +775,14 @@ const transform = function(original_options = {}) { if(this.state.field.length !== 0){ // In relax_quotes mode, treat opening quote preceded by chrs as regular if(relax_quotes === false){ + const info = this.__infoField(); + const bom = Object.keys(boms).map(b => boms[b].equals(this.state.field.toString()) ? b : false).filter(Boolean)[0]; const err = this.__error( new CsvError('INVALID_OPENING_QUOTE', [ 'Invalid Opening Quote:', - `a quote is found inside a field at line ${this.info.lines}`, - ], this.options, this.__infoField(), { + `a quote is found on field ${JSON.stringify(info.column)} at line ${info.lines}, value is ${JSON.stringify(this.state.field.toString(encoding))}`, + bom ? `(${bom} bom)` : undefined + ], this.options, info, { field: this.state.field, }) ); diff --git a/packages/csv-parse/dist/cjs/sync.cjs b/packages/csv-parse/dist/cjs/sync.cjs index 8d3bacf89..bb5ee4dfb 100644 --- a/packages/csv-parse/dist/cjs/sync.cjs +++ b/packages/csv-parse/dist/cjs/sync.cjs @@ -2,7 +2,7 @@ class CsvError extends Error { constructor(code, message, options, ...contexts) { - if(Array.isArray(message)) message = message.join(' '); + if(Array.isArray(message)) message = message.join(' ').trim(); super(message); if(Error.captureStackTrace !== undefined){ Error.captureStackTrace(this, CsvError); @@ -637,7 +637,7 @@ const transform = function(original_options = {}) { }, // Central parser implementation parse: function(nextBuf, end, push, close){ - const {bom, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; + const {bom, encoding, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; let {comment, escape, quote, record_delimiter} = this.options; const {bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this.state; let buf; @@ -773,11 +773,14 @@ const transform = function(original_options = {}) { if(this.state.field.length !== 0){ // In relax_quotes mode, treat opening quote preceded by chrs as regular if(relax_quotes === false){ + const info = this.__infoField(); + const bom = Object.keys(boms).map(b => boms[b].equals(this.state.field.toString()) ? b : false).filter(Boolean)[0]; const err = this.__error( new CsvError('INVALID_OPENING_QUOTE', [ 'Invalid Opening Quote:', - `a quote is found inside a field at line ${this.info.lines}`, - ], this.options, this.__infoField(), { + `a quote is found on field ${JSON.stringify(info.column)} at line ${info.lines}, value is ${JSON.stringify(this.state.field.toString(encoding))}`, + bom ? `(${bom} bom)` : undefined + ], this.options, info, { field: this.state.field, }) ); diff --git a/packages/csv-parse/dist/esm/index.js b/packages/csv-parse/dist/esm/index.js index 41e3b64fb..e6af55763 100644 --- a/packages/csv-parse/dist/esm/index.js +++ b/packages/csv-parse/dist/esm/index.js @@ -5066,7 +5066,7 @@ const is_object = function(obj){ class CsvError extends Error { constructor(code, message, options, ...contexts) { - if(Array.isArray(message)) message = message.join(' '); + if(Array.isArray(message)) message = message.join(' ').trim(); super(message); if(Error.captureStackTrace !== undefined){ Error.captureStackTrace(this, CsvError); @@ -5697,7 +5697,7 @@ const transform = function(original_options = {}) { }, // Central parser implementation parse: function(nextBuf, end, push, close){ - const {bom, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; + const {bom, encoding, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; let {comment, escape, quote, record_delimiter} = this.options; const {bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this.state; let buf; @@ -5833,11 +5833,14 @@ const transform = function(original_options = {}) { if(this.state.field.length !== 0){ // In relax_quotes mode, treat opening quote preceded by chrs as regular if(relax_quotes === false){ + const info = this.__infoField(); + const bom = Object.keys(boms).map(b => boms[b].equals(this.state.field.toString()) ? b : false).filter(Boolean)[0]; const err = this.__error( new CsvError('INVALID_OPENING_QUOTE', [ 'Invalid Opening Quote:', - `a quote is found inside a field at line ${this.info.lines}`, - ], this.options, this.__infoField(), { + `a quote is found on field ${JSON.stringify(info.column)} at line ${info.lines}, value is ${JSON.stringify(this.state.field.toString(encoding))}`, + bom ? `(${bom} bom)` : undefined + ], this.options, info, { field: this.state.field, }) ); diff --git a/packages/csv-parse/dist/esm/sync.js b/packages/csv-parse/dist/esm/sync.js index c40ae6ff1..09cf2f247 100644 --- a/packages/csv-parse/dist/esm/sync.js +++ b/packages/csv-parse/dist/esm/sync.js @@ -1972,7 +1972,7 @@ function isSlowBuffer (obj) { class CsvError extends Error { constructor(code, message, options, ...contexts) { - if(Array.isArray(message)) message = message.join(' '); + if(Array.isArray(message)) message = message.join(' ').trim(); super(message); if(Error.captureStackTrace !== undefined){ Error.captureStackTrace(this, CsvError); @@ -2607,7 +2607,7 @@ const transform = function(original_options = {}) { }, // Central parser implementation parse: function(nextBuf, end, push, close){ - const {bom, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; + const {bom, encoding, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; let {comment, escape, quote, record_delimiter} = this.options; const {bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this.state; let buf; @@ -2743,11 +2743,14 @@ const transform = function(original_options = {}) { if(this.state.field.length !== 0){ // In relax_quotes mode, treat opening quote preceded by chrs as regular if(relax_quotes === false){ + const info = this.__infoField(); + const bom = Object.keys(boms).map(b => boms[b].equals(this.state.field.toString()) ? b : false).filter(Boolean)[0]; const err = this.__error( new CsvError('INVALID_OPENING_QUOTE', [ 'Invalid Opening Quote:', - `a quote is found inside a field at line ${this.info.lines}`, - ], this.options, this.__infoField(), { + `a quote is found on field ${JSON.stringify(info.column)} at line ${info.lines}, value is ${JSON.stringify(this.state.field.toString(encoding))}`, + bom ? `(${bom} bom)` : undefined + ], this.options, info, { field: this.state.field, }) ); diff --git a/packages/csv-parse/dist/iife/index.js b/packages/csv-parse/dist/iife/index.js index 53cac4439..35ce1565b 100644 --- a/packages/csv-parse/dist/iife/index.js +++ b/packages/csv-parse/dist/iife/index.js @@ -5069,7 +5069,7 @@ var csv_parse = (function (exports) { class CsvError extends Error { constructor(code, message, options, ...contexts) { - if(Array.isArray(message)) message = message.join(' '); + if(Array.isArray(message)) message = message.join(' ').trim(); super(message); if(Error.captureStackTrace !== undefined){ Error.captureStackTrace(this, CsvError); @@ -5700,7 +5700,7 @@ var csv_parse = (function (exports) { }, // Central parser implementation parse: function(nextBuf, end, push, close){ - const {bom, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; + const {bom, encoding, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; let {comment, escape, quote, record_delimiter} = this.options; const {bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this.state; let buf; @@ -5836,11 +5836,14 @@ var csv_parse = (function (exports) { if(this.state.field.length !== 0){ // In relax_quotes mode, treat opening quote preceded by chrs as regular if(relax_quotes === false){ + const info = this.__infoField(); + const bom = Object.keys(boms).map(b => boms[b].equals(this.state.field.toString()) ? b : false).filter(Boolean)[0]; const err = this.__error( new CsvError('INVALID_OPENING_QUOTE', [ 'Invalid Opening Quote:', - `a quote is found inside a field at line ${this.info.lines}`, - ], this.options, this.__infoField(), { + `a quote is found on field ${JSON.stringify(info.column)} at line ${info.lines}, value is ${JSON.stringify(this.state.field.toString(encoding))}`, + bom ? `(${bom} bom)` : undefined + ], this.options, info, { field: this.state.field, }) ); diff --git a/packages/csv-parse/dist/iife/sync.js b/packages/csv-parse/dist/iife/sync.js index c55d3269f..bbd9a751a 100644 --- a/packages/csv-parse/dist/iife/sync.js +++ b/packages/csv-parse/dist/iife/sync.js @@ -1975,7 +1975,7 @@ var csv_parse_sync = (function (exports) { class CsvError extends Error { constructor(code, message, options, ...contexts) { - if(Array.isArray(message)) message = message.join(' '); + if(Array.isArray(message)) message = message.join(' ').trim(); super(message); if(Error.captureStackTrace !== undefined){ Error.captureStackTrace(this, CsvError); @@ -2610,7 +2610,7 @@ var csv_parse_sync = (function (exports) { }, // Central parser implementation parse: function(nextBuf, end, push, close){ - const {bom, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; + const {bom, encoding, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; let {comment, escape, quote, record_delimiter} = this.options; const {bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this.state; let buf; @@ -2746,11 +2746,14 @@ var csv_parse_sync = (function (exports) { if(this.state.field.length !== 0){ // In relax_quotes mode, treat opening quote preceded by chrs as regular if(relax_quotes === false){ + const info = this.__infoField(); + const bom = Object.keys(boms).map(b => boms[b].equals(this.state.field.toString()) ? b : false).filter(Boolean)[0]; const err = this.__error( new CsvError('INVALID_OPENING_QUOTE', [ 'Invalid Opening Quote:', - `a quote is found inside a field at line ${this.info.lines}`, - ], this.options, this.__infoField(), { + `a quote is found on field ${JSON.stringify(info.column)} at line ${info.lines}, value is ${JSON.stringify(this.state.field.toString(encoding))}`, + bom ? `(${bom} bom)` : undefined + ], this.options, info, { field: this.state.field, }) ); diff --git a/packages/csv-parse/dist/umd/index.js b/packages/csv-parse/dist/umd/index.js index 587435bf2..555295853 100644 --- a/packages/csv-parse/dist/umd/index.js +++ b/packages/csv-parse/dist/umd/index.js @@ -5072,7 +5072,7 @@ class CsvError extends Error { constructor(code, message, options, ...contexts) { - if(Array.isArray(message)) message = message.join(' '); + if(Array.isArray(message)) message = message.join(' ').trim(); super(message); if(Error.captureStackTrace !== undefined){ Error.captureStackTrace(this, CsvError); @@ -5703,7 +5703,7 @@ }, // Central parser implementation parse: function(nextBuf, end, push, close){ - const {bom, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; + const {bom, encoding, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; let {comment, escape, quote, record_delimiter} = this.options; const {bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this.state; let buf; @@ -5839,11 +5839,14 @@ if(this.state.field.length !== 0){ // In relax_quotes mode, treat opening quote preceded by chrs as regular if(relax_quotes === false){ + const info = this.__infoField(); + const bom = Object.keys(boms).map(b => boms[b].equals(this.state.field.toString()) ? b : false).filter(Boolean)[0]; const err = this.__error( new CsvError('INVALID_OPENING_QUOTE', [ 'Invalid Opening Quote:', - `a quote is found inside a field at line ${this.info.lines}`, - ], this.options, this.__infoField(), { + `a quote is found on field ${JSON.stringify(info.column)} at line ${info.lines}, value is ${JSON.stringify(this.state.field.toString(encoding))}`, + bom ? `(${bom} bom)` : undefined + ], this.options, info, { field: this.state.field, }) ); diff --git a/packages/csv-parse/dist/umd/sync.js b/packages/csv-parse/dist/umd/sync.js index c0ad953fd..1c4fe5822 100644 --- a/packages/csv-parse/dist/umd/sync.js +++ b/packages/csv-parse/dist/umd/sync.js @@ -1978,7 +1978,7 @@ class CsvError extends Error { constructor(code, message, options, ...contexts) { - if(Array.isArray(message)) message = message.join(' '); + if(Array.isArray(message)) message = message.join(' ').trim(); super(message); if(Error.captureStackTrace !== undefined){ Error.captureStackTrace(this, CsvError); @@ -2613,7 +2613,7 @@ }, // Central parser implementation parse: function(nextBuf, end, push, close){ - const {bom, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; + const {bom, encoding, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; let {comment, escape, quote, record_delimiter} = this.options; const {bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this.state; let buf; @@ -2749,11 +2749,14 @@ if(this.state.field.length !== 0){ // In relax_quotes mode, treat opening quote preceded by chrs as regular if(relax_quotes === false){ + const info = this.__infoField(); + const bom = Object.keys(boms).map(b => boms[b].equals(this.state.field.toString()) ? b : false).filter(Boolean)[0]; const err = this.__error( new CsvError('INVALID_OPENING_QUOTE', [ 'Invalid Opening Quote:', - `a quote is found inside a field at line ${this.info.lines}`, - ], this.options, this.__infoField(), { + `a quote is found on field ${JSON.stringify(info.column)} at line ${info.lines}, value is ${JSON.stringify(this.state.field.toString(encoding))}`, + bom ? `(${bom} bom)` : undefined + ], this.options, info, { field: this.state.field, }) ); diff --git a/packages/csv-parse/lib/api/CsvError.js b/packages/csv-parse/lib/api/CsvError.js index b22a847a9..1af83534c 100644 --- a/packages/csv-parse/lib/api/CsvError.js +++ b/packages/csv-parse/lib/api/CsvError.js @@ -1,7 +1,7 @@ class CsvError extends Error { constructor(code, message, options, ...contexts) { - if(Array.isArray(message)) message = message.join(' '); + if(Array.isArray(message)) message = message.join(' ').trim(); super(message); if(Error.captureStackTrace !== undefined){ Error.captureStackTrace(this, CsvError); diff --git a/packages/csv-parse/lib/api/index.js b/packages/csv-parse/lib/api/index.js index 9f90a06a7..b71843ba9 100644 --- a/packages/csv-parse/lib/api/index.js +++ b/packages/csv-parse/lib/api/index.js @@ -61,7 +61,7 @@ const transform = function(original_options = {}) { }, // Central parser implementation parse: function(nextBuf, end, push, close){ - const {bom, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; + const {bom, encoding, from_line, ltrim, max_record_size,raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this.options; let {comment, escape, quote, record_delimiter} = this.options; const {bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this.state; let buf; @@ -197,11 +197,14 @@ const transform = function(original_options = {}) { if(this.state.field.length !== 0){ // In relax_quotes mode, treat opening quote preceded by chrs as regular if(relax_quotes === false){ + const info = this.__infoField(); + const bom = Object.keys(boms).map(b => boms[b].equals(this.state.field.toString()) ? b : false).filter(Boolean)[0]; const err = this.__error( new CsvError('INVALID_OPENING_QUOTE', [ 'Invalid Opening Quote:', - `a quote is found inside a field at line ${this.info.lines}`, - ], this.options, this.__infoField(), { + `a quote is found on field ${JSON.stringify(info.column)} at line ${info.lines}, value is ${JSON.stringify(this.state.field.toString(encoding))}`, + bom ? `(${bom} bom)` : undefined + ], this.options, info, { field: this.state.field, }) ); diff --git a/packages/csv-parse/test/api.events.coffee b/packages/csv-parse/test/api.events.coffee index f3cabba77..0eed9db97 100644 --- a/packages/csv-parse/test/api.events.coffee +++ b/packages/csv-parse/test/api.events.coffee @@ -46,7 +46,7 @@ describe 'API events', -> ''' parser = parse (err) -> assert_error err, - message: 'Invalid Opening Quote: a quote is found inside a field at line 1' + message: 'Invalid Opening Quote: a quote is found on field 0 at line 1, value is " x "' code: 'INVALID_OPENING_QUOTE' field: ' x ' next() diff --git a/packages/csv-parse/test/info.lines.coffee b/packages/csv-parse/test/info.lines.coffee index 2ca70db26..c836fa460 100644 --- a/packages/csv-parse/test/info.lines.coffee +++ b/packages/csv-parse/test/info.lines.coffee @@ -43,7 +43,7 @@ describe 'properties lines', -> "and",valid,line,follows... """, (err, records) -> assert_error err, - message: 'Invalid Opening Quote: a quote is found inside a field at line 3' + message: 'Invalid Opening Quote: a quote is found on field 4 at line 3, value is "h"' code: 'INVALID_OPENING_QUOTE' field: 'h' (records == undefined).should.be.true @@ -58,7 +58,7 @@ describe 'properties lines', -> "and",valid,line,follows... """, skip_empty_lines: true, (err, records) -> assert_error err, - message: 'Invalid Opening Quote: a quote is found inside a field at line 4' + message: 'Invalid Opening Quote: a quote is found on field 3 at line 4, value is "invalid h"' code: 'INVALID_OPENING_QUOTE' field: 'invalid h' (records == undefined).should.be.true diff --git a/packages/csv-parse/test/option.bom.coffee b/packages/csv-parse/test/option.bom.coffee index d20198b20..938b3af4b 100644 --- a/packages/csv-parse/test/option.bom.coffee +++ b/packages/csv-parse/test/option.bom.coffee @@ -56,7 +56,7 @@ describe 'Option `bom`', -> it 'throw parsing error if quote follow bom', (next) -> parser = parse (err) -> assert_error err, - message: 'Invalid Opening Quote: a quote is found inside a field at line 1' + message: 'Invalid Opening Quote: a quote is found on field 0 at line 1, value is "\ufeff" (utf8 bom)' code: 'INVALID_OPENING_QUOTE' field: '\ufeff' next() diff --git a/packages/csv-parse/test/option.ltrim.coffee b/packages/csv-parse/test/option.ltrim.coffee index 1c3e17235..3c9d2d1ee 100644 --- a/packages/csv-parse/test/option.ltrim.coffee +++ b/packages/csv-parse/test/option.ltrim.coffee @@ -53,7 +53,7 @@ describe 'Option `ltrim`', -> ''' parser = parse ltrim: true, (err) -> assert_error err, - message: 'Invalid Opening Quote: a quote is found inside a field at line 1' + message: 'Invalid Opening Quote: a quote is found on field 0 at line 1, value is "x "' code: 'INVALID_OPENING_QUOTE' field: 'x ' next() diff --git a/packages/csv-parse/test/option.quote.coffee b/packages/csv-parse/test/option.quote.coffee index 398fa08d6..f3b0dc93c 100644 --- a/packages/csv-parse/test/option.quote.coffee +++ b/packages/csv-parse/test/option.quote.coffee @@ -195,7 +195,7 @@ describe 'Option `quote`', -> describe 'error "Invalid opening quotes"', -> - it 'count empty lines', (next) -> + it 'on indexed columns', (next) -> parse """ "this","line","is",valid "this","line",is,"also,valid" @@ -203,9 +203,22 @@ describe 'Option `quote`', -> "and",valid,line,follows... """, (err, records) -> assert_error err, - message: 'Invalid Opening Quote: a quote is found inside a field at line 3' + message: 'Invalid Opening Quote: a quote is found on field 3 at line 3, value is "invalid h"' code: 'INVALID_OPENING_QUOTE' field: 'invalid h' (records == undefined).should.be.true next() + + it 'on indexed columns', (next) -> + parse """ + "a","b","c","d" + "11","12",13,"14" + 21,"22",23,2"4" + """, columns: true, (err, records) -> + assert_error err, + message: 'Invalid Opening Quote: a quote is found on field "d" at line 3, value is "2"' + code: 'INVALID_OPENING_QUOTE' + field: '2' + (records == undefined).should.be.true + next() diff --git a/packages/csv-parse/test/option.relax_quotes.coffee b/packages/csv-parse/test/option.relax_quotes.coffee index 909b2955b..98c2046df 100644 --- a/packages/csv-parse/test/option.relax_quotes.coffee +++ b/packages/csv-parse/test/option.relax_quotes.coffee @@ -33,7 +33,7 @@ describe 'Option `relax_quotes`', -> 384682,the "SAMAY" Hostel,Jiron Florida 285 """, relax_quotes: false, (err) -> assert_error err, - message: 'Invalid Opening Quote: a quote is found inside a field at line 1' + message: 'Invalid Opening Quote: a quote is found on field 1 at line 1, value is "the "' code: 'INVALID_OPENING_QUOTE' field: 'the ' next() @@ -104,7 +104,7 @@ describe 'Option `relax_quotes`', -> a,b "c" """, relax_quotes: false, (err) -> assert_error err, - message: 'Invalid Opening Quote: a quote is found inside a field at line 1' + message: 'Invalid Opening Quote: a quote is found on field 1 at line 1, value is "b "' code: 'INVALID_OPENING_QUOTE' field: 'b ' next() diff --git a/packages/csv-parse/test/option.skip_records_with_error.coffee b/packages/csv-parse/test/option.skip_records_with_error.coffee index 41f7cfe22..85ccfd33c 100644 --- a/packages/csv-parse/test/option.skip_records_with_error.coffee +++ b/packages/csv-parse/test/option.skip_records_with_error.coffee @@ -47,11 +47,11 @@ describe 'Option `skip_records_with_error`', -> ["line", "3"] ] unless err assert_error errors, [ - message: 'Invalid Opening Quote: a quote is found inside a field at line 2' + message: 'Invalid Opening Quote: a quote is found on field 1 at line 2, value is "invalid h"' code: 'INVALID_OPENING_QUOTE' field: 'invalid h' , - message: 'Invalid Opening Quote: a quote is found inside a field at line 2' + message: 'Invalid Opening Quote: a quote is found on field 1 at line 2, value is "invalid h\\"ere"' code: 'INVALID_OPENING_QUOTE' field: 'invalid h"ere' ]