You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2011/01/25 18:03:30 UTC
svn commit: r1063354 - in /lucene/dev/branches/branch_3x: ./ lucene/ solr/
solr/src/java/org/apache/solr/handler/CSVRequestHandler.java
Author: gsingers
Date: Tue Jan 25 17:03:29 2011
New Revision: 1063354
URL: http://svn.apache.org/viewvc?rev=1063354&view=rev
Log:
SOLR-482: backport CSV exception handling to 3x
Modified:
lucene/dev/branches/branch_3x/ (props changed)
lucene/dev/branches/branch_3x/lucene/ (props changed)
lucene/dev/branches/branch_3x/solr/ (props changed)
lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/handler/CSVRequestHandler.java
Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/handler/CSVRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/handler/CSVRequestHandler.java?rev=1063354&r1=1063353&r2=1063354&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/handler/CSVRequestHandler.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/handler/CSVRequestHandler.java Tue Jan 25 17:03:29 2011
@@ -317,12 +317,27 @@ abstract class CSVLoader extends Content
private void input_err(String msg, String[] line, int lineno) {
StringBuilder sb = new StringBuilder();
- sb.append(errHeader+", line="+lineno + ","+msg+"\n\tvalues={");
- for (String val: line) { sb.append("'"+val+"',"); }
+ sb.append(errHeader).append(", line=").append(lineno).append(",").append(msg).append("\n\tvalues={");
+ for (String val: line) {
+ sb.append("'").append(val).append("',"); }
sb.append('}');
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,sb.toString());
}
+ private void input_err(String msg, String[] lines, int lineNo, Throwable e) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(errHeader).append(", line=").append(lineNo).append(",").append(msg).append("\n\tvalues={");
+ if (lines != null) {
+ for (String val : lines) {
+ sb.append("'").append(val).append("',");
+ }
+ } else {
+ sb.append("NO LINES AVAILABLE");
+ }
+ sb.append('}');
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,sb.toString(), e);
+ }
+
/** load the CSV input */
public void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream) throws IOException {
errHeader = "CSVLoader: input=" + stream.getSourceInfo();
@@ -353,7 +368,13 @@ abstract class CSVLoader extends Content
// read the rest of the CSV file
for(;;) {
int line = parser.getLineNumber(); // for error reporting in MT mode
- String[] vals = parser.getLine();
+ String[] vals = null;
+ try {
+ vals = parser.getLine();
+ } catch (IOException e) {
+ //Catch the exception and rethrow it with more line information
+ input_err("can't read line: " + line, null, line, e);
+ }
if (vals==null) break;
if (vals.length != fields.length) {