no exception thread dump if parser cannot parse becuase that mime-type/extension is in the deny-set

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6611 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent 0098e6e859
commit 69c29acb6e

@ -1599,7 +1599,7 @@ public final class Switchboard extends serverSwitch {
document = TextParser.parseSource(response.url(), response.getMimeType(), response.getCharacterEncoding(), b); document = TextParser.parseSource(response.url(), response.getMimeType(), response.getCharacterEncoding(), b);
assert(document != null) : "Unexpected error. Parser returned null."; assert(document != null) : "Unexpected error. Parser returned null.";
} catch (final ParserException e) { } catch (final ParserException e) {
this.log.logWarning("Unable to parse the resource '" + response.url() + "'. " + e.getMessage(), e); this.log.logWarning("Unable to parse the resource '" + response.url() + "'. " + e.getMessage());
addURLtoErrorDB(response.url(), response.referrerHash(), response.initiator(), response.name(), e.getMessage()); addURLtoErrorDB(response.url(), response.referrerHash(), response.initiator(), response.name(), e.getMessage());
if (document != null) { if (document != null) {
document.close(); document.close();

@ -214,13 +214,15 @@ public final class TextParser {
mimeType = normalizeMimeType(mimeType); mimeType = normalizeMimeType(mimeType);
final String fileExt = location.getFileExtension(); final String fileExt = location.getFileExtension();
final String documentCharset = htmlParser.patchCharsetEncoding(charset); final String documentCharset = htmlParser.patchCharsetEncoding(charset);
List<Idiom> idioms = idiomParser(location, mimeType); List<Idiom> idioms = null;
try {
if (idioms.isEmpty()) { idioms = idiomParser(location, mimeType);
final String errorMsg = "No parser available to parse extension '" + location.getFileExtension() + "' or mimetype '" + mimeType + "'"; } catch (ParserException e) {
log.logInfo("Unable to parse '" + location + "'. " + errorMsg); final String errorMsg = "Parser Failure for extension '" + location.getFileExtension() + "' or mimetype '" + mimeType + "': " + e.getMessage();
log.logWarning(errorMsg);
throw new ParserException(errorMsg, location); throw new ParserException(errorMsg, location);
} }
assert !idioms.isEmpty();
if (log.isFine()) log.logInfo("Parsing " + location + " with mimeType '" + mimeType + "' and file extension '" + fileExt + "'."); if (log.isFine()) log.logInfo("Parsing " + location + " with mimeType '" + mimeType + "' and file extension '" + fileExt + "'.");
@ -310,6 +312,9 @@ public final class TextParser {
idiom = mime2parser.get(mimeType2); idiom = mime2parser.get(mimeType2);
if (idiom != null && !idioms.contains(idiom)) idioms.add(idiom); if (idiom != null && !idioms.contains(idiom)) idioms.add(idiom);
// finall check if we found any parser
if (idioms.isEmpty()) throw new ParserException("no parser found for extension '" + ext + "' and mime type '" + mimeType1 + "'", url);
return idioms; return idioms;
} }

Loading…
Cancel
Save