Revision: 18436 http://sourceforge.net/p/gate/code/18436 Author: ian_roberts Date: 2014-11-06 19:03:45 +0000 (Thu, 06 Nov 2014) Log Message: ----------- Follow the same logic as other doc formats - only throw an exception on failed parse if the "throwExceptionOnFormatError" document feature is set.
Modified Paths: -------------- gate/trunk/plugins/Twitter/src/gate/corpora/JSONTweetFormat.java Modified: gate/trunk/plugins/Twitter/src/gate/corpora/JSONTweetFormat.java =================================================================== --- gate/trunk/plugins/Twitter/src/gate/corpora/JSONTweetFormat.java 2014-11-06 19:01:41 UTC (rev 18435) +++ gate/trunk/plugins/Twitter/src/gate/corpora/JSONTweetFormat.java 2014-11-06 19:03:45 UTC (rev 18436) @@ -24,6 +24,8 @@ import gate.creole.metadata.CreoleResource; import gate.util.DocumentFormatException; import gate.util.InvalidOffsetException; +import gate.util.Out; + import java.io.IOException; import java.util.HashMap; import java.util.Iterator; @@ -117,11 +119,23 @@ } } } - catch (InvalidOffsetException e) { - throw new DocumentFormatException(e); - } - catch(IOException e) { - throw new DocumentFormatException(e); + catch (InvalidOffsetException | IOException e) { + doc.getFeatures().put("parsingError", Boolean.TRUE); + + Boolean bThrow = + (Boolean)doc.getFeatures().get( + GateConstants.THROWEX_FORMAT_PROPERTY_NAME); + + if(bThrow != null && bThrow.booleanValue()) { + // the next line is commented to avoid Document creation fail on + // error + throw new DocumentFormatException(e); + } + else { + Out.println("Warning: Document remains unparsed. \n" + + "\n Stack Dump: "); + e.printStackTrace(Out.getPrintWriter()); + } // if } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ GATE-cvs mailing list GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs