mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 16:58:51 -05:00
* better error reporting
This commit is contained in:
parent
c7e25998fb
commit
d054c50c18
@ -1,7 +1,5 @@
|
||||
|
||||
package net.sourceforge.filebot.cli;
|
||||
|
||||
|
||||
import static java.lang.System.*;
|
||||
|
||||
import java.io.PrintStream;
|
||||
@ -10,58 +8,55 @@ 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);
|
||||
|
||||
|
||||
// don't use parent handlers
|
||||
log.setUseParentHandlers(false);
|
||||
|
||||
|
||||
// CLI handler
|
||||
log.addHandler(new CLILogging());
|
||||
|
||||
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
if (record.getLevel().intValue() <= getLevel().intValue())
|
||||
return;
|
||||
|
||||
|
||||
// make sure all previous messages are already flushed
|
||||
System.out.flush();
|
||||
System.err.flush();
|
||||
|
||||
|
||||
// use either System.out or System.err depending on the severity of the error
|
||||
PrintStream out = record.getLevel().intValue() < Level.WARNING.intValue() ? System.out : System.err;
|
||||
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -89,7 +89,10 @@ 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) {
|
||||
Logger.getLogger(TMDbClient.class.getName()).log(Level.WARNING, String.format("Ignore movie [%s]: %s", title, e.getMessage()));
|
||||
// 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;
|
||||
|
@ -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);
|
||||
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;
|
||||
}
|
||||
TheTVDBSearchResult series = new TheTVDBSearchResult(name, id);
|
||||
getCache().putData("lookupByID", id, locale, series);
|
||||
return series;
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user