Improved errror messages for when TheTVDB is down and sends back invalid xml.
e.g. ``` <?xml version="1.0" encoding="UTF-8" ?> Could not connect: Too many connections ```
This commit is contained in:
parent
86ce5e7e8c
commit
ec0b0038e6
|
@ -25,6 +25,7 @@ import org.w3c.dom.Document;
|
|||
import net.filebot.util.ByteBufferInputStream;
|
||||
import net.filebot.util.ByteBufferOutputStream;
|
||||
import net.filebot.util.JsonUtilities;
|
||||
import net.filebot.web.InvalidResponseException;
|
||||
import net.filebot.web.WebRequest;
|
||||
|
||||
public class CachedResource<K, R> implements Resource<R> {
|
||||
|
@ -98,12 +99,13 @@ public class CachedResource<K, R> implements Resource<R> {
|
|||
|
||||
return parse.transform(data);
|
||||
} catch (Exception e) {
|
||||
debug.severe(format("Fetch failed: %s [%s]", e, url));
|
||||
debug.log(Level.SEVERE, "Fetch failed: " + url, e);
|
||||
|
||||
// use previously cached data if possible
|
||||
if (element == null || element.getObjectValue() == null) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return element.getObjectValue();
|
||||
}
|
||||
});
|
||||
|
@ -169,8 +171,7 @@ public class CachedResource<K, R> implements Resource<R> {
|
|||
WebRequest.validateXml(xml);
|
||||
return xml;
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, xml, e);
|
||||
throw e;
|
||||
throw new InvalidResponseException("Invalid XML", xml, e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -182,8 +183,7 @@ public class CachedResource<K, R> implements Resource<R> {
|
|||
JsonUtilities.readJson(json);
|
||||
return json;
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, json, e);
|
||||
throw e;
|
||||
throw new InvalidResponseException("Invalid JSON", json, e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ import net.filebot.web.AudioTrackFormat;
|
|||
import net.filebot.web.Episode;
|
||||
import net.filebot.web.EpisodeFormat;
|
||||
import net.filebot.web.EpisodeListProvider;
|
||||
import net.filebot.web.InvalidResponseException;
|
||||
import net.filebot.web.Movie;
|
||||
import net.filebot.web.MovieFormat;
|
||||
import net.filebot.web.MovieIdentificationService;
|
||||
|
@ -904,8 +905,21 @@ public class RenamePanel extends JComponent {
|
|||
// add remaining file entries
|
||||
renameModel.files().addAll(remainingFiles);
|
||||
} catch (Exception e) {
|
||||
// ignore cancellation exception
|
||||
if (findCause(e, CancellationException.class) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// common error message
|
||||
if (findCause(e, InvalidResponseException.class) != null) {
|
||||
log.log(Level.WARNING, findCause(e, InvalidResponseException.class).getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
// generic error message
|
||||
if (findCause(e, CancellationException.class) == null) {
|
||||
log.log(Level.WARNING, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), e);
|
||||
return;
|
||||
}
|
||||
} finally {
|
||||
// auto-match finished
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package net.filebot.web;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class InvalidResponseException extends IOException {
|
||||
|
||||
public InvalidResponseException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public InvalidResponseException(String message, String content, Throwable cause) {
|
||||
super(String.format("%s: %s: %s\n%s", message, cause.getClass().getSimpleName(), cause.getMessage(), content), cause);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue