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
This commit is contained in:
orbiter 2010-01-22 13:21:37 +00:00
parent 0098e6e859
commit 69c29acb6e
2 changed files with 11 additions and 6 deletions

View File

@ -1599,7 +1599,7 @@ public final class Switchboard extends serverSwitch {
document = TextParser.parseSource(response.url(), response.getMimeType(), response.getCharacterEncoding(), b);
assert(document != null) : "Unexpected error. Parser returned null.";
} 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());
if (document != null) {
document.close();

View File

@ -214,13 +214,15 @@ public final class TextParser {
mimeType = normalizeMimeType(mimeType);
final String fileExt = location.getFileExtension();
final String documentCharset = htmlParser.patchCharsetEncoding(charset);
List<Idiom> idioms = idiomParser(location, mimeType);
if (idioms.isEmpty()) {
final String errorMsg = "No parser available to parse extension '" + location.getFileExtension() + "' or mimetype '" + mimeType + "'";
log.logInfo("Unable to parse '" + location + "'. " + errorMsg);
List<Idiom> idioms = null;
try {
idioms = idiomParser(location, mimeType);
} catch (ParserException e) {
final String errorMsg = "Parser Failure for extension '" + location.getFileExtension() + "' or mimetype '" + mimeType + "': " + e.getMessage();
log.logWarning(errorMsg);
throw new ParserException(errorMsg, location);
}
assert !idioms.isEmpty();
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);
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;
}