commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven Peterson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CSV-147) Better error handling in CSV, see included code
Date Tue, 13 Jan 2015 15:57:34 GMT

    [ https://issues.apache.org/jira/browse/CSV-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14275432#comment-14275432
] 

Steven Peterson commented on CSV-147:
-------------------------------------

Benedikt Ritter: I have tried wrapping the nextRecord() method in a try/catch block, but there
is no way (AFAIK)  to get the data that caused the problem.  The exception thrown returns
the line number, but not the actual partial record.  And the CSVParser class does not seem
to provide any methods for accessing its state once an exception has been thrown.  A method
exposing the partial current record would go a long way to helping identify the error.  Do
you have a suggestion as to how I could get the examine the data parsed after catching an
exception?

Gary Gregory: I would be glad to make a patch and a junit test; I will put this together.

> Better error handling in CSV, see included code
> -----------------------------------------------
>
>                 Key: CSV-147
>                 URL: https://issues.apache.org/jira/browse/CSV-147
>             Project: Commons CSV
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.1
>            Reporter: Steven Peterson
>              Labels: easyfix
>             Fix For: Discussion
>
>   Original Estimate: 0.25h
>  Remaining Estimate: 0.25h
>
> When parsing long files, and there is problem with parsing the data, it would be very
useful to know the exact data that is bad when an exception is thrown.  As CSVParser maintains
a portion of the current record that was read when an exception is thrown (in the 'record'
property), can we make this information public through something like this:
> {code:java}
> public String[] getLastRecordData() {
>   return this.record.toArray(new String[this.record.size()]);
> }
> {code}
> With a method like this, it would be easy to pull in part of the data that was in the
faulty record after an exception was thrown, aiding in cleaning up the data.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message