@@ -14,7 +14,7 @@ class TCsvParseException : public TMisuseException {
1414 if (ColumnName.has_value ()) {
1515 *this << " Csv parsing error on line " << Line << " in column \" " << ColumnName << " \" : " ;
1616 } else {
17- *this << " Csv parsing error on line " << Line << " \" : " ;
17+ *this << " Csv parsing error on line " << Line << " : " ;
1818 }
1919 }
2020
@@ -323,11 +323,19 @@ TValue TCsvParser::FieldToValue(TTypeParser& parser, TStringBuf token) const {
323323 return converter.Convert (token);
324324}
325325
326+ TStringBuf TCsvParser::Consume (NCsvFormat::CsvSplitter& splitter) const {
327+ try {
328+ return splitter.Consume ();
329+ } catch (std::exception& e) {
330+ throw TCsvParseException () << e.what ();
331+ }
332+ }
333+
326334void TCsvParser::GetParams (TString&& data, TParamsBuilder& builder) const {
327335 NCsvFormat::CsvSplitter splitter (data, Delimeter);
328336 auto headerIt = Header.begin ();
329337 do {
330- TStringBuf token = splitter. Consume ();
338+ TStringBuf token = Consume (splitter );
331339 if (headerIt == Header.end ()) {
332340 throw TCsvParseException () << " Header contains less fields than data. Header: \" " << HeaderRow << " \" , data: \" " << data << " \" " ;
333341 }
@@ -362,7 +370,7 @@ void TCsvParser::GetValue(TString&& data, TValueBuilder& builder, const TType& t
362370 auto headerIt = Header.cbegin ();
363371 std::map<TString, TStringBuf> fields;
364372 do {
365- TStringBuf token = splitter. Consume () ;
373+ TStringBuf token = Consume (splitter); ;
366374 if (headerIt == Header.cend ()) {
367375 throw TCsvParseException () << " Header contains less fields than data. Header: \" " << HeaderRow << " \" , data: \" " << data << " \" " ;
368376 }
0 commit comments