@@ -5066,7 +5066,7 @@ const is_object = function(obj){
5066
5066
5067
5067
class CsvError extends Error {
5068
5068
constructor ( code , message , options , ...contexts ) {
5069
- if ( Array . isArray ( message ) ) message = message . join ( ' ' ) ;
5069
+ if ( Array . isArray ( message ) ) message = message . join ( ' ' ) . trim ( ) ;
5070
5070
super ( message ) ;
5071
5071
if ( Error . captureStackTrace !== undefined ) {
5072
5072
Error . captureStackTrace ( this , CsvError ) ;
@@ -5697,7 +5697,7 @@ const transform = function(original_options = {}) {
5697
5697
} ,
5698
5698
// Central parser implementation
5699
5699
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 ;
5701
5701
let { comment, escape, quote, record_delimiter} = this . options ;
5702
5702
const { bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this . state ;
5703
5703
let buf ;
@@ -5833,11 +5833,14 @@ const transform = function(original_options = {}) {
5833
5833
if ( this . state . field . length !== 0 ) {
5834
5834
// In relax_quotes mode, treat opening quote preceded by chrs as regular
5835
5835
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 ] ;
5836
5838
const err = this . __error (
5837
5839
new CsvError ( 'INVALID_OPENING_QUOTE' , [
5838
5840
'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 , {
5841
5844
field : this . state . field ,
5842
5845
} )
5843
5846
) ;
0 commit comments