Re: [Htmlparser-user] Not able to catch ParserException
Brought to you by:
derrickoswald
From: Martin S. <mst...@gm...> - 2007-01-10 16:31:33
|
Hi, Are you sure you are running your own program? StringExtractor is only a sample application for the StringBean, so it woul= d be better to use the StringBean directly instead of StringExtractor. I did not experience your problem (I use StringBean rather intensively) and it would mean that the ParserException is catched somewhere in the HTMLParser codebase and printed directly to standard out. This is not very likely I think. However, the main() method of StringExtractor does catch ParserException an= d print it to standard out. Maybe you can try to use StringBean directly insttead of StringExtractor: String content =3D ""; try { StringBean sb; sb =3D new StringBean (); sb.setLinks (false); sb.setURL (url); content =3D sb.getStrings(); System.out.println(content); } catch (ParserException e) { logger.error("Could not parse url", e); System.out.println("test"); } -- Martin Sturm 2007/1/10, =D8ystein Lervik Larsen <oys...@me...>: > > Hi list! :-] > > I seem to have a problem catching the ParserException when using > StringExtractor. > > My console says: > org.htmlparser.util.ParserException: Exception getting input stream from > (and so on...) > > ...but my logger (log4j) does not print and the string "test" is not > written to the console. > > > String content =3D ""; > try { > StringExtractor se =3D new StringExtractor(url); > content =3D se.extractStrings(false); > System.out.println(content); > } > catch(ParserException e){ > logger.error("Could not parse url",e); > System.out.println("test"); > } > > > Could the exception be handled some place else that I'm not aware of? > The string "content" is sometimes empty due to a 401 error. > > Thanks in advance for any reply! > > Best regards, > =D8ystein > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > |