# HG changeset patch # User Jaroslav Tulach # Date 1417716420 -3600 # Node ID 2ca94af8496afdaccd7f7c427386da5100c5490c # Parent cf1b6ff9bf0691322936874f1f82fc6ec9722e84 status 0 is used when the network is not available diff -r cf1b6ff9bf06 -r 2ca94af8496a rt/emul/mini/src/main/java/java/net/URL.java --- a/rt/emul/mini/src/main/java/java/net/URL.java Wed Dec 03 20:27:39 2014 +0100 +++ b/rt/emul/mini/src/main/java/java/net/URL.java Thu Dec 04 19:07:00 2014 +0100 @@ -1008,27 +1008,33 @@ * @see java.net.URLConnection#getContent() */ public final Object getContent() throws java.io.IOException { - return loadText(toExternalForm()); + try { + return loadText(toExternalForm()); + } catch (Throwable ex) { + throw new IOException(ex.getMessage()); + } } @JavaScriptBody(args = "url", body = "" + "var request = new XMLHttpRequest();\n" + "request.open('GET', url, false);\n" + "request.send();\n" + + "if (request.status === 0) throw 'Network error';\n" + "return request.responseText;\n" ) - private static native String loadText(String url) throws IOException; + private static native String loadText(String url) throws Throwable; @JavaScriptBody(args = { "url", "arr" }, body = "" + "var request = new XMLHttpRequest();\n" + "request.open('GET', url, false);\n" + "request.overrideMimeType('text\\/plain; charset=x-user-defined');\n" + "request.send();\n" + + "if (request.status === 0) throw 'Network error';\n" + "var t = request.responseText;\n" + "for (var i = 0; i < t.length; i++) arr.push(t.charCodeAt(i) & 0xff);\n" + "return arr;\n" ) - private static native Object loadBytes(String url, byte[] arr) throws IOException; + private static native Object loadBytes(String url, byte[] arr) throws Throwable; /** * Gets the contents of this URL. This method is a shorthand for: @@ -1055,7 +1061,7 @@ return loadBytes(toExternalForm(), new byte[0]); } } catch (Throwable t) { - throw new IOException(t); + throw new IOException(t.getMessage()); } } return null;