1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-25 09:18:51 -05:00

* better error reporting

This commit is contained in:
Reinhard Pointner 2013-10-20 13:10:21 +00:00
parent c7e25998fb
commit d054c50c18
3 changed files with 26 additions and 34 deletions

View File

@ -1,7 +1,5 @@
package net.sourceforge.filebot.cli;
import static java.lang.System.*;
import java.io.PrintStream;
@ -10,12 +8,12 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.codehaus.groovy.runtime.StackTraceUtils;
class CLILogging extends Handler {
public static final Logger CLILogger = createCommandlineLogger("net.sourceforge.filebot.logger.cli");
private static Logger createCommandlineLogger(String name) {
Logger log = Logger.getLogger(name);
log.setLevel(Level.ALL);
@ -29,7 +27,6 @@ class CLILogging extends Handler {
return log;
}
@Override
public void publish(LogRecord record) {
if (record.getLevel().intValue() <= getLevel().intValue())
@ -45,20 +42,18 @@ class CLILogging extends Handler {
// print messages
out.println(record.getMessage());
if (record.getThrown() != null) {
record.getThrown().printStackTrace(out);
StackTraceUtils.deepSanitize(record.getThrown()).printStackTrace(out);
}
// flush every message immediately
out.flush();
}
@Override
public void close() throws SecurityException {
}
@Override
public void flush() {
out.flush();

View File

@ -89,9 +89,12 @@ public class TMDbClient implements MovieIdentificationService {
}
result.add(new Movie(title, title.equals(originalTitle) ? new String[] {} : new String[] { originalTitle }, year, -1, (int) id));
} catch (Exception e) {
// only print 'missing release date' warnings for matching movie titles
if (query.equalsIgnoreCase(title) || query.equalsIgnoreCase(originalTitle)) {
Logger.getLogger(TMDbClient.class.getName()).log(Level.WARNING, String.format("Ignore movie [%s]: %s", title, e.getMessage()));
}
}
}
return result;
}

View File

@ -185,18 +185,12 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
return cachedItem;
}
try {
Document dom = getXmlResource(MirrorType.XML, "/api/" + apikey + "/series/" + id + "/all/" + getLanguageCode(locale) + ".xml");
String name = selectString("//SeriesName", dom);
TheTVDBSearchResult series = new TheTVDBSearchResult(name, id);
getCache().putData("lookupByID", id, locale, series);
return series;
} catch (FileNotFoundException e) {
// illegal series id
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Failed to retrieve base series record: " + e.getMessage());
return null;
}
}
public TheTVDBSearchResult lookupByIMDbID(int imdbid, Locale locale) throws Exception {
@ -291,7 +285,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
try {
return resource.getDocument();
} catch (FileNotFoundException e) {
throw new FileNotFoundException("Resource not found: " + getResourceURL(mirrorType, path)); // simplify error message
throw new IllegalArgumentException("Resource not found: " + getResourceURL(mirrorType, path)); // simplify error message
}
}