From c3caf6e63a3567aec9bc4390b3ddfde3510e15e3 Mon Sep 17 00:00:00 2001 From: dsyer Date: Tue, 18 Dec 2007 10:23:34 +0000 Subject: [PATCH] RESOLVED - issue BATCH-259: FlatFileParsingException should include line number in its toString() http://opensource.atlassian.com/projects/spring/browse/BATCH-259 --- .../io/file/support/SimpleFlatFileItemReader.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/support/SimpleFlatFileItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/support/SimpleFlatFileItemReader.java index 1a920eb6c..f7eacf99e 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/support/SimpleFlatFileItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/support/SimpleFlatFileItemReader.java @@ -77,6 +77,8 @@ public class SimpleFlatFileItemReader extends AbstractItemReader implements Item private int linesToSkip = 0; + private String path; + /** * Setter for resource property. The location of an input stream that can be * read. @@ -86,6 +88,10 @@ public class SimpleFlatFileItemReader extends AbstractItemReader implements Item */ public void setResource(Resource resource) throws IOException { this.resource = resource; + path = resource.toString(); + if (path.length()>50) { + path = path.substring(0,20)+"..."+path.substring(path.length()); + } } /** @@ -196,8 +202,9 @@ public class SimpleFlatFileItemReader extends AbstractItemReader implements Item return fieldSetMapper.mapLine(tokenizedLine); } catch (RuntimeException ex) { // add current line count to message and re-throw - throw new FlatFileParsingException("Parsing error", ex, line, - getReader().getCurrentLineCount()); + int lineCount = getReader().getCurrentLineCount(); + throw new FlatFileParsingException("Parsing error at line: "+lineCount+" in resource="+path+", input=["+line+"]", ex, line, + lineCount); } } return null;