From: Niki Roo Date: Sat, 2 Dec 2017 15:33:14 +0000 (+0100) Subject: Fix remote save, better GUI if bad import url X-Git-Tag: fanfix-1.6.3~11 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=fd1d31c20100442f3c2480b8177a2df761613a15;p=fanfix.git Fix remote save, better GUI if bad import url --- diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index 430fb20..42c6c9d 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -4,6 +4,7 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.URL; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -368,13 +369,15 @@ abstract public class BasicLibrary { * * @return the imported {@link Story} * + * @throws UnknownHostException + * if the host is not supported * @throws IOException * in case of I/O error */ public Story imprt(URL url, Progress pg) throws IOException { BasicSupport support = BasicSupport.getSupport(url); if (support == null) { - throw new IOException("URL not supported: " + url.toString()); + throw new UnknownHostException("" + url); } return save(support.process(url, pg), null); diff --git a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java index 84d763f..6a62b6f 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java @@ -130,7 +130,7 @@ public class RemoteLibraryServer extends ServerObject { } Story story = rebuildStory(list); - Instance.getLibrary().save(story, "" + args[1], null); + Instance.getLibrary().save(story, "" + args[0], null); } else if ("DELETE_STORY".equals(command)) { Instance.getLibrary().delete("" + args[0]); } else if ("GET_COVER".equals(command)) { diff --git a/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java b/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java index 4e2630e..9174380 100644 --- a/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java @@ -13,6 +13,7 @@ import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; import java.net.URL; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -987,8 +988,13 @@ class GuiReaderFrame extends JFrame { pgOnSuccess.setProgress(0); if (!ok) { - error("Cannot import URL", "Failed to import " + url - + ": \n" + e.getMessage(), e); + if (e instanceof UnknownHostException) { + error("Failed to import " + url, "Cannot import URL", + null); + } else { + error("Failed to import " + url + ": \n" + + e.getMessage(), "Cannot import URL", e); + } } else { if (onSuccess != null) { onSuccess.run(story);