1.1 --- a/rt/emul/mini/src/main/java/java/net/URL.java Wed Dec 03 20:27:39 2014 +0100
1.2 +++ b/rt/emul/mini/src/main/java/java/net/URL.java Thu Dec 04 19:07:00 2014 +0100
1.3 @@ -1008,27 +1008,33 @@
1.4 * @see java.net.URLConnection#getContent()
1.5 */
1.6 public final Object getContent() throws java.io.IOException {
1.7 - return loadText(toExternalForm());
1.8 + try {
1.9 + return loadText(toExternalForm());
1.10 + } catch (Throwable ex) {
1.11 + throw new IOException(ex.getMessage());
1.12 + }
1.13 }
1.14
1.15 @JavaScriptBody(args = "url", body = ""
1.16 + "var request = new XMLHttpRequest();\n"
1.17 + "request.open('GET', url, false);\n"
1.18 + "request.send();\n"
1.19 + + "if (request.status === 0) throw 'Network error';\n"
1.20 + "return request.responseText;\n"
1.21 )
1.22 - private static native String loadText(String url) throws IOException;
1.23 + private static native String loadText(String url) throws Throwable;
1.24
1.25 @JavaScriptBody(args = { "url", "arr" }, body = ""
1.26 + "var request = new XMLHttpRequest();\n"
1.27 + "request.open('GET', url, false);\n"
1.28 + "request.overrideMimeType('text\\/plain; charset=x-user-defined');\n"
1.29 + "request.send();\n"
1.30 + + "if (request.status === 0) throw 'Network error';\n"
1.31 + "var t = request.responseText;\n"
1.32 + "for (var i = 0; i < t.length; i++) arr.push(t.charCodeAt(i) & 0xff);\n"
1.33 + "return arr;\n"
1.34 )
1.35 - private static native Object loadBytes(String url, byte[] arr) throws IOException;
1.36 + private static native Object loadBytes(String url, byte[] arr) throws Throwable;
1.37
1.38 /**
1.39 * Gets the contents of this URL. This method is a shorthand for:
1.40 @@ -1055,7 +1061,7 @@
1.41 return loadBytes(toExternalForm(), new byte[0]);
1.42 }
1.43 } catch (Throwable t) {
1.44 - throw new IOException(t);
1.45 + throw new IOException(t.getMessage());
1.46 }
1.47 }
1.48 return null;