@@ -5066,7 +5066,7 @@ const is_object = function(obj){
50665066
50675067class CsvError extends Error {
50685068 constructor ( code , message , options , ...contexts ) {
5069- if ( Array . isArray ( message ) ) message = message . join ( ' ' ) ;
5069+ if ( Array . isArray ( message ) ) message = message . join ( ' ' ) . trim ( ) ;
50705070 super ( message ) ;
50715071 if ( Error . captureStackTrace !== undefined ) {
50725072 Error . captureStackTrace ( this , CsvError ) ;
@@ -5697,7 +5697,7 @@ const transform = function(original_options = {}) {
56975697 } ,
56985698 // Central parser implementation
56995699 parse : function ( nextBuf , end , push , close ) {
5700- const { bom, from_line, ltrim, max_record_size, raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this . options ;
5700+ const { bom, encoding , from_line, ltrim, max_record_size, raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this . options ;
57015701 let { comment, escape, quote, record_delimiter} = this . options ;
57025702 const { bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this . state ;
57035703 let buf ;
@@ -5833,11 +5833,14 @@ const transform = function(original_options = {}) {
58335833 if ( this . state . field . length !== 0 ) {
58345834 // In relax_quotes mode, treat opening quote preceded by chrs as regular
58355835 if ( relax_quotes === false ) {
5836+ const info = this . __infoField ( ) ;
5837+ const bom = Object . keys ( boms ) . map ( b => boms [ b ] . equals ( this . state . field . toString ( ) ) ? b : false ) . filter ( Boolean ) [ 0 ] ;
58365838 const err = this . __error (
58375839 new CsvError ( 'INVALID_OPENING_QUOTE' , [
58385840 'Invalid Opening Quote:' ,
5839- `a quote is found inside a field at line ${ this . info . lines } ` ,
5840- ] , this . options , this . __infoField ( ) , {
5841+ `a quote is found on field ${ JSON . stringify ( info . column ) } at line ${ info . lines } , value is ${ JSON . stringify ( this . state . field . toString ( encoding ) ) } ` ,
5842+ bom ? `(${ bom } bom)` : undefined
5843+ ] , this . options , info , {
58415844 field : this . state . field ,
58425845 } )
58435846 ) ;
0 commit comments