/** * Process connection response data. * * @param conn connection to read response data from. * @return assembled response as string. * @throws IOException on I/O error */ private StringBuilder readResponse(URLConnection conn) throws IOException { StringBuilder retval = new StringBuilder(); HttpURLConnection http = (HttpURLConnection) conn; int resp = 200; try { resp = http.getResponseCode(); } catch (Throwable ex) { } if (resp >= 200 && resp < 300) { BufferedReader input = null; try { input = new BufferedReader(new InputStreamReader(conn.getInputStream())); } catch (Throwable ex) { retval.append(ex.toString()); return retval; } String line = null; while ((line = input.readLine()) != null) { retval.append(line); retval.append("\n"); } input.close(); } else { retval.append(http.getResponseMessage()); } LogContext.getLogger().finer(String.format("<-- HTTP Response: %d: %s", resp, retval)); return retval; }
@Override public void parseRequestParameters( final Map<String, String> params, final Map<String, com.bradmcevoy.http.FileItem> files) throws RequestParseException { try { if (isMultiPart()) { parseQueryString(params, req.getQueryString()); @SuppressWarnings("unchecked") final List<FileItem> items = new ServletFileUpload().parseRequest(req); for (final FileItem item : items) { if (item.isFormField()) params.put(item.getFieldName(), item.getString()); else files.put(item.getFieldName(), new FileItemWrapper(item)); } } else { final Enumeration<String> en = req.getParameterNames(); while (en.hasMoreElements()) { final String nm = en.nextElement(); final String val = req.getParameter(nm); params.put(nm, val); } } } catch (final FileUploadException ex) { throw new RequestParseException("FileUploadException", ex); } catch (final Throwable ex) { throw new RequestParseException(ex.getMessage(), ex); } }
/** ** Main client thread loop */ public void run() { this.setRunStatus(THREAD_RUNNING); this.threadStarted(); try { this.openSocket(); this.inputThread = new InputThread(this.socket, this.readTimeout, this.ioThreadLock); this.outputThread = new OutputThread(this.socket, this.ioThreadLock); this.inputThread.start(); this.outputThread.start(); synchronized (this.ioThreadLock) { while (this.inputThread.isRunning() || this.outputThread.isRunning()) { try { this.ioThreadLock.wait(); } catch (Throwable t) { } } } } catch (NoRouteToHostException nrthe) { Print.logInfo("Client:ControlThread - Unable to reach " + this.host + ":" + this.port); nrthe.printStackTrace(); } catch (Throwable t) { Print.logInfo("Client:ControlThread - " + t); t.printStackTrace(); } finally { this.closeSocket(); } this.setRunStatus(THREAD_STOPPED); this.threadStopped(); }
public static void main(String args[]) { // The stat reporter writes out the test info and results // into the top-level quicklook directory during a run. stat.addDescription("http-listener reader-threads unit tests."); String host = args[0]; String portS = args[1]; String contextRoot = args[2]; int port = new Integer(portS).intValue(); String name; try { goGet(host, port, "FILTER", contextRoot + "/ServletTest"); } catch (Throwable t) { System.out.println(t.getMessage()); } if (count != EXPECTED_COUNT) { stat.addStatus("web-readerThreadsConfig", stat.FAIL); } stat.printSummary("web/standalonewar---> expect " + EXPECTED_COUNT); }
/** * Returns an string array representation of the specified throwable. * * @param th throwable * @return string array */ private static String[] toArray(final Throwable th) { final StackTraceElement[] st = th.getStackTrace(); final String[] obj = new String[st.length + 1]; obj[0] = th.toString(); for (int i = 0; i < st.length; i++) obj[i + 1] = " " + st[i]; return obj; }
public static void main(String args[]) { // The stat reporter writes out the test info and results // into the top-level quicklook directory during a run. stat.addDescription("Unit test for IT 13555"); WebTest webTest = new WebTest(args); int port = new Integer(webTest.portS).intValue(); String name; try { webTest.goGet(webTest.host, port, webTest.contextRoot + "/test"); } catch (Throwable t) { System.out.println(t.getMessage()); stat.addStatus(" Test " + TEST_NAME + " UNPREDICTED-FAILURE", stat.FAIL); } finally { try { if (webTest.sock != null) { webTest.sock.close(); } } catch (IOException ioe) { // ignore } } stat.printSummary(TEST_NAME + " ---> PASS"); }
public void runPreProcess() { Authorization auth = new glguerin.authkit.imp.macosx.MacOSXAuthorization(); Privilege priv = new Privilege("system.privilege.admin"); // see kAuthorizationRightExecute in the AuthorizationTags.h from Security.framework int count = 0; boolean succeed = false; do { try { auth.authorize(priv, true); succeed = true; break; } catch (Throwable t) { System.out.println("Throwable " + t); } count++; } while (count <= 3); if (succeed) { String preinstallPath = createTemporaryPreinstallFile(); if (preinstallPath == null) return; String[] progArray = {preinstallPath, System.getProperty("user.name")}; try { Process p = auth.execPrivileged(progArray); Thread.sleep(1000L); } catch (Throwable t) { System.out.println("Throwable " + t); t.printStackTrace(); } } }
/** * Processes a packet read from either the multicast or unicast socket. Needs to be synchronized * because mcast or unicast socket reads can be concurrent */ void handleIncomingUdpPacket(byte[] data) { ByteArrayInputStream inp_stream; ObjectInputStream inp; Message msg = null; List l; // used if bundling is enabled try { // skip the first n bytes (default: 4), this is the version info inp_stream = new ByteArrayInputStream(data, VERSION_LENGTH, data.length - VERSION_LENGTH); inp = new ObjectInputStream(inp_stream); if (enable_bundling) { l = new List(); l.readExternal(inp); for (Enumeration en = l.elements(); en.hasMoreElements(); ) { msg = (Message) en.nextElement(); try { handleMessage(msg); } catch (Throwable t) { Trace.error("UDP.handleIncomingUdpPacket()", "failure: " + t.toString()); } } } else { msg = new Message(); msg.readExternal(inp); handleMessage(msg); } } catch (Throwable e) { Trace.error("UDP.handleIncomingUdpPacket()", "exception=" + Trace.getStackTrace(e)); } }
public void run() { StringBuffer data = new StringBuffer(); Print.logDebug("Client:InputThread started"); while (true) { data.setLength(0); boolean timeout = false; try { if (this.readTimeout > 0L) { this.socket.setSoTimeout((int) this.readTimeout); } ClientSocketThread.socketReadLine(this.socket, -1, data); } catch (InterruptedIOException ee) { // SocketTimeoutException ee) { // error("Read interrupted (timeout) ..."); if (getRunStatus() != THREAD_RUNNING) { break; } timeout = true; // continue; } catch (Throwable t) { Print.logError("Client:InputThread - " + t); t.printStackTrace(); break; } if (!timeout || (data.length() > 0)) { ClientSocketThread.this.handleMessage(data.toString()); } } synchronized (this.threadLock) { this.isRunning = false; Print.logDebug("Client:InputThread stopped"); this.threadLock.notify(); } }
public void run() { Throwable t = null; while (canRun()) { Buffer data = null; try { data = send_queue.take(); if (data.hashCode() == termination.hashCode()) break; } catch (InterruptedException e) { t = e; break; } if (data != null) { try { _send(data.getBuf(), 0, data.getLength(), false, send_queue.isEmpty()); } catch (Throwable ignored) { t = ignored; } } } server.notifyConnectionClosed( TcpConnection.this, String.format( "%s: %s", getClass().getSimpleName(), t != null ? t.toString() : "normal stop")); }
Object createGuiElement(Class cls, EntityPlayer player, World world, int x, int y, int z) { try { try { if (debugGui) System.out.printf( "BaseMod.createGuiElement: Invoking create method of %s for %s in %s\n", cls, player, world); return cls.getMethod( "create", EntityPlayer.class, World.class, int.class, int.class, int.class) .invoke(null, player, world, x, y, z); } catch (NoSuchMethodException e) { if (debugGui) System.out.printf("BaseMod.createGuiElement: Invoking constructor of %s\n", cls); return cls.getConstructor(EntityPlayer.class, World.class, int.class, int.class, int.class) .newInstance(player, world, x, y, z); } } catch (Exception e) { Throwable cause = e.getCause(); System.out.printf("BaseMod.createGuiElement: %s: %s\n", e, cause); if (cause != null) cause.printStackTrace(); else e.printStackTrace(); // throw new RuntimeException(e); return null; } }
public static void main(String[] args) { try { COConfigurationManager.initialise(); boolean v6 = true; // Test connectivity. if (true) { // System.out.println( "UDP: " + getSingleton().getExternalIpAddressUDP(null,0,v6)); // System.out.println( "TCP: " + getSingleton().getExternalIpAddressTCP(null,0,v6)); // System.out.println( "HTTP: " + getSingleton().getExternalIpAddressHTTP(v6)); } Map data = constructVersionCheckMessage(VersionCheckClient.REASON_UPDATE_CHECK_START); System.out.println("Sending (pre-initialisation):"); printDataMap(data); System.out.println("-----------"); System.out.println("Receiving (pre-initialisation):"); printDataMap( getSingleton().getVersionCheckInfo(VersionCheckClient.REASON_UPDATE_CHECK_START)); System.out.println("-----------"); System.out.println(); System.out.print("Initialising core... "); /** * Suppress all of these errors being displayed in the output. * * <p>These things should be temporary... */ AzureusCoreImpl.SUPPRESS_CLASSLOADER_ERRORS = true; DownloadManagerStateImpl.SUPPRESS_FIXUP_ERRORS = true; AzureusCore core = AzureusCoreFactory.create(); core.start(); System.out.println("done."); System.out.println(); System.out.println("-----------"); data = constructVersionCheckMessage(VersionCheckClient.REASON_UPDATE_CHECK_START); System.out.println("Sending (post-initialisation):"); printDataMap(data); System.out.println("-----------"); System.out.println("Receiving (post-initialisation):"); printDataMap( getSingleton().getVersionCheckInfo(VersionCheckClient.REASON_UPDATE_CHECK_START)); System.out.println("-----------"); System.out.println(); System.out.print("Shutting down core... "); core.stop(); System.out.println("done."); } catch (Throwable e) { e.printStackTrace(); } }
private String lookupFarm() { if (Response != null) { if (Response.isStillValid()) { return Response.getFarmID(); } Response = null; } try { InetAddress CDPServer; DatagramSocket Socket; CDPQuery Query; byte[] Buffer; DatagramPacket Packet; /* Get the IP address of the CDP servers. */ CDPServer = InetAddress.getByName(CDPServerName); /* Create a UDP socket for the CDP query. */ Socket = new DatagramSocket(); Socket.setSoTimeout(CDPTimeout); /* Build the CDP query. */ Query = new CDPQuery(Constants.AZUREUS_NAME + " " + Constants.AZUREUS_VERSION); Buffer = Query.getBytes(); Packet = new DatagramPacket(Buffer, Buffer.length, CDPServer, CDPPort); /* Send the query to the CDP server. */ Socket.send(Packet); /* Receive the CDP response. */ Buffer = new byte[CDPResponse.MaxSize]; Packet.setData(Buffer); Socket.receive(Packet); if (Packet.getAddress() != CDPServer || Packet.getPort() != CDPPort) throw (new Exception("CDP server address mismatch on response")); /* Parse the CDP response. */ Response = new CDPResponse(Packet.getData()); /* Return the farmID from the CDP response. */ return Response.getFarmID(); } catch (Throwable Excpt) { if (Excpt instanceof UnknownHostException) { } else { Excpt.printStackTrace(); } return "default"; } }
/** * ** Invokes all listeners with an assciated command ** @param r a string that may specify a * command (possibly one ** of several) associated with the event */ protected void invokeListeners(String r) { if (this.actionListeners != null) { for (Iterator i = this.actionListeners.iterator(); i.hasNext(); ) { ActionListener al = (ActionListener) i.next(); ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, r); try { al.actionPerformed(ae); } catch (Throwable t) { Print.logError("Exception: " + t.getMessage()); } } } }
/** * Returns a more user-friendly error message for the specified exception. * * @param ex throwable reference * @return error message */ public static String message(final Throwable ex) { debug(ex); if (ex instanceof BindException) return SRV_RUNNING; if (ex instanceof LoginException) return ACCESS_DENIED; if (ex instanceof ConnectException) return CONNECTION_ERROR; if (ex instanceof SocketTimeoutException) return TIMEOUT_EXCEEDED; if (ex instanceof SocketException) return CONNECTION_ERROR; String msg = ex.getMessage(); if (msg == null || msg.isEmpty()) msg = ex.toString(); if (ex instanceof FileNotFoundException) return info(RES_NOT_FOUND_X, msg); if (ex instanceof UnknownHostException) return info(UNKNOWN_HOST_X, msg); return msg; }
/** * Fired when a control is clicked. This is the equivalent of * ActionListener.actionPerformed(ActionEvent e). */ protected void actionPerformed(GuiButton par1GuiButton) { if (par1GuiButton.enabled) { if (par1GuiButton.id == 5) { if (Minecraft.getOs() == EnumOS.MACOS) { try { this.mc.getLogAgent().logInfo(this.fileLocation); Runtime.getRuntime().exec(new String[] {"/usr/bin/open", this.fileLocation}); return; } catch (IOException var7) { var7.printStackTrace(); } } else if (Minecraft.getOs() == EnumOS.WINDOWS) { String var2 = String.format( "cmd.exe /C start \"Open file\" \"%s\"", new Object[] {this.fileLocation}); try { Runtime.getRuntime().exec(var2); return; } catch (IOException var6) { var6.printStackTrace(); } } boolean var8 = false; try { Class var3 = Class.forName("java.awt.Desktop"); Object var4 = var3.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]); var3.getMethod("browse", new Class[] {URI.class}) .invoke( var4, new Object[] {(new File(Minecraft.getMinecraftDir(), "texturepacks")).toURI()}); } catch (Throwable var5) { var5.printStackTrace(); var8 = true; } if (var8) { this.mc.getLogAgent().logInfo("Opening via system class!"); Sys.openURL("file://" + this.fileLocation); } } else if (par1GuiButton.id == 6) { this.mc.displayGuiScreen(this.guiScreen); } else { this.guiTexturePackSlot.actionPerformed(par1GuiButton); } } }
private String[] store(String names[], long size, int i, NameValueRecord nvr) { // store file boolean error1 = false; while (true) { boolean error = false; try { names = createFileAndStore(names, size, binary, metadata, nvr, true, times, 0); // nvr = retrieveMetadata(names[1], times, 0); } catch (HoneycombTestException e) { flex("store size=" + size + " name=" + (names == null ? "null" : names[0]), e); log.log("store problem: " + e.getMessage()); // e.printStackTrace(); error = true; } catch (Throwable t) { flex("store size=" + size + " name=" + (names == null ? "null" : names[0]), t); log.log("store: got throwable"); t.printStackTrace(); error = true; } if (error) { error1 = true; store_retries++; sleep(SLEEP); continue; } break; } if (error1) flog("#E ok\n"); // save info total_files++; total_bytes += size; store_bytes += size; time_store += times[0]; total_store_time += times[0]; oids[i] = names[1]; shas[i] = names[2]; if (fo != null) { String s = "" + size + '\t' + names[0] + '\t' + // filename names[1] + '\t' + // oid names[2] + '\t' + // sha1 names[3] + '\t' + // store date binary + '\t' + metadata + '\t' + times[0] + '\n'; flog(s); } return names; }
/** * Shows an error and a short description. * * @param ex the exception */ static void showError(Throwable ex, String title, String message) { try { if (title == null) title = "Error in SIP contactlist storage"; if (message == null) message = title + "\n" + ex.getClass().getName() + ": " + ex.getLocalizedMessage(); if (SipActivator.getUIService() != null) SipActivator.getUIService() .getPopupDialog() .showMessagePopupDialog(message, title, PopupDialog.ERROR_MESSAGE); } catch (Throwable t) { logger.error("Error for error dialog", t); } }
/** * Try to execute given method on given object. Handles invocation target exceptions. XXX nearly * duplicates tryMethod in JGEngine. * * @return null means method does not exist or returned null/void */ static Object tryMethod(Object o, String name, Object[] args) { try { Method met = JREEngine.getMethod(o.getClass(), name, args); if (met == null) return null; return met.invoke(o, args); } catch (InvocationTargetException ex) { Throwable ex_t = ex.getTargetException(); ex_t.printStackTrace(); return null; } catch (IllegalAccessException ex) { System.err.println("Unexpected exception:"); ex.printStackTrace(); return null; } }
private void sendProcessingError(Throwable t, ServletResponse response) { String stackTrace = getStackTrace(t); if (stackTrace != null && !stackTrace.equals("")) { try { response.setContentType("text/html"); PrintStream ps = new PrintStream(response.getOutputStream()); PrintWriter pw = new PrintWriter(ps); pw.print("<html>\n<head>\n</head>\n<body>\n"); // NOI18N // PENDING! Localize this for next official release pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n"); pw.print(stackTrace); pw.print("</pre></body>\n</html>"); // NOI18N pw.close(); ps.close(); response.getOutputStream().close(); ; } catch (Exception ex) { } } else { try { PrintStream ps = new PrintStream(response.getOutputStream()); t.printStackTrace(ps); ps.close(); response.getOutputStream().close(); ; } catch (Exception ex) { } } }
boolean _error(Throwable t) throws MongoException { if (_allHosts != null) { System.out.println("paired mode, switching master b/c of: " + t); t.printStackTrace(); _pickCurrent(); } return true; }
public static void main(String[] args) { try { TOTorrent torrent = TOTorrentFactory.deserialiseFromBEncodedFile(new File("C:\\temp\\test.torrent")); CachePeer[] peers = new CLCacheDiscovery().lookup(torrent); System.out.println("peers=" + peers.length); for (int i = 0; i < peers.length; i++) { System.out.println(" cache: " + peers[i].getAddress() + ":" + peers[i].getPort()); } } catch (Throwable e) { e.printStackTrace(); } }
public static boolean exec(String cmd) throws Exception { int exitVal = -1; try { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(new String[] {"/bin/bash", "-c", cmd}); OutputHandler err = new OutputHandler(proc.getErrorStream(), cmd); err.start(); OutputHandler out = new OutputHandler(proc.getInputStream(), cmd); out.start(); exitVal = proc.waitFor(); } catch (Throwable t) { t.printStackTrace(); } return (exitVal == 0); }
public void run() { String command = null; Print.logInfo("Client:OutputThread started"); while (true) { /* wait for commands */ synchronized (this.cmdList) { while ((this.cmdList.size() <= 0) && (getRunStatus() == THREAD_RUNNING)) { try { this.cmdList.wait(5000L); } catch (Throwable t) { /*ignore*/ } } if (getRunStatus() != THREAD_RUNNING) { break; } command = this.cmdList.remove(0).toString(); } /* send commands */ try { ClientSocketThread.socketWriteLine(this.socket, command); } catch (Throwable t) { Print.logError("Client:OutputThread - " + t); t.printStackTrace(); break; } } if (getRunStatus() == THREAD_RUNNING) { Print.logWarn("Client:OutputThread stopped due to error"); } else { Print.logInfo("Client:OutputThread stopped"); } synchronized (this.threadLock) { this.isRunning = false; Print.logInfo("Client:OutputThread stopped"); this.threadLock.notify(); } }
// // The main work loop // public void run() { // // Poll the Namenode (once every 5 minutes) to find the size of the // pending edit log. // long period = 5 * 60; // 5 minutes long lastCheckpointTime = 0; if (checkpointPeriod < period) { period = checkpointPeriod; } while (shouldRun) { try { Thread.sleep(1000 * period); } catch (InterruptedException ie) { // do nothing } if (!shouldRun) { break; } try { long now = System.currentTimeMillis(); long size = namenode.getEditLogSize(); if (size >= checkpointSize || now >= lastCheckpointTime + 1000 * checkpointPeriod) { doCheckpoint(); lastCheckpointTime = now; } } catch (IOException e) { LOG.error("Exception in doCheckpoint: "); LOG.error(StringUtils.stringifyException(e)); e.printStackTrace(); checkpointImage.imageDigest = null; } catch (Throwable e) { LOG.error("Throwable Exception in doCheckpoint: "); LOG.error(StringUtils.stringifyException(e)); e.printStackTrace(); Runtime.getRuntime().exit(-1); } } }
/* * Receive an exception. If the resolution has been completed, * do nothing. Otherwise make progress. */ public void handleException(Object id, Exception e) { if (Options.check("verbose")) System.err.println("ExtendedResolver: got " + e); synchronized (this) { outstanding--; if (done) return; int n; for (n = 0; n < inprogress.length; n++) if (inprogress[n] == id) break; /* If we don't know what this is, do nothing. */ if (n == inprogress.length) return; boolean startnext = false; boolean waiting = false; /* * If this is the first response from server n, * we should start sending queries to server n + 1. */ if (sent[n] == 1 && n < resolvers.length - 1) startnext = true; if (e instanceof InterruptedIOException) { /* Got a timeout; resend */ if (sent[n] < retries) send(n); if (thrown == null) thrown = e; } else if (e instanceof SocketException) { /* * Problem with the socket; don't resend * on it */ if (thrown == null || thrown instanceof InterruptedIOException) thrown = e; } else { /* * Problem with the response; don't resend * on the same socket. */ thrown = e; } if (done) return; if (startnext) send(n + 1); if (done) return; if (outstanding == 0) { /* * If we're done and this is synchronous, * wake up the blocking thread. */ done = true; if (listener == null) { notifyAll(); return; } } if (!done) return; } /* If we're done and this is asynchronous, call the callback. */ if (!(thrown instanceof Exception)) thrown = new RuntimeException(thrown.getMessage()); listener.handleException(this, (Exception) thrown); }
protected void log(String str, Throwable e) { if (device_manager == null) { System.out.println(str); e.printStackTrace(); } else { device_manager.log("TiVo: " + str, e); } }
public static void main(String[] pArgs) { if (pArgs.length < 3) { System.out.println("usage: java Client host port boardnum"); return; } try { Socket lSocket = new Socket(pArgs[0], Integer.parseInt(pArgs[1])); PrintWriter lOut = new PrintWriter(lSocket.getOutputStream()); BufferedReader lIn = new BufferedReader(new InputStreamReader(lSocket.getInputStream())); lOut.println(pArgs[2]); lOut.flush(); String lLine = lIn.readLine(); // read number of rows int lNumRows = Integer.parseInt(lLine); // now, we should find a path from the player to any goal // we've found our solution String lMySol = SokobanSolver.findSolution(Matrix.tileMatrixFromBufferedReader(lIn, lNumRows)); // these formats are also valid: // String lMySol="URRUULDLLULLDRRRRLDDRURUDLLUR"; // String lMySol="0 3 3 0 0 2 1 2 2 0 2 2 1 3 3 3 3 2 1 1 3 0 3 0 1 2 2 0 3"; // send the solution to the server lOut.println(lMySol); lOut.flush(); // read answer from the server lLine = lIn.readLine(); System.out.println(lLine); } catch (Throwable t) { t.printStackTrace(); } }
/** * 运行时,添加JVM参数“-Dsun.net.http.retryPost=false”,可阻止自动重连。 * * @see 'http://www.coderanch.com/t/490463/sockets/java/Timeout-retry-URLHTTPRequest' */ @Test public void testConnectionResetByHttpURLConnection() throws IOException { testConnectionResetCount = 0; String resp = null; try { HttpURLConnection conn = (HttpURLConnection) new URL("http://localhost:65532/soso").openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.getOutputStream().write("username".getBytes()); resp = conn.getResponseCode() + ""; } catch (IOException e) { Throwable ee = ExceptionUtils.getRootCause(e); if (ee == null) { ee = e; } Logger.error(this, "", ee); Assert.assertNotSame(NoHttpResponseException.class, ee.getClass()); Assert.assertSame(SocketException.class, ee.getClass()); Assert.assertTrue( "Connection reset".equals(ee.getMessage()) || "Socket closed".equals(ee.getMessage()) || "Unexpected end of file from server".equals(ee.getMessage())); } finally { Logger.info( this, "resp[HttpURLConnection]-[" + testConnectionResetCount + "]=========[" + resp + "]========="); } Assert.assertEquals(2, testConnectionResetCount); }
public void setData(String text) { if (text != null && text.length() > 0) { InputStream in = null; try { Object result = null; Drawing drawing = createDrawing(); // Try to read the data using all known input formats. for (InputFormat fmt : drawing.getInputFormats()) { try { fmt.read(in, drawing); in = new ByteArrayInputStream(text.getBytes("UTF8")); result = drawing; break; } catch (IOException e) { result = e; } } if (result instanceof IOException) { throw (IOException) result; } setDrawing(drawing); } catch (Throwable e) { getDrawing().removeAllChildren(); SVGTextFigure tf = new SVGTextFigure(); tf.setText(e.getMessage()); tf.setBounds(new Point2D.Double(10, 10), new Point2D.Double(100, 100)); getDrawing().add(tf); e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (IOException ex) { ex.printStackTrace(); } } } } }