1 package thinlet.drafts; 2 3 import java.io.*; 4 import thinlet.*; 5 6 9 public class ExceptionDialog { 10 11 14 public ExceptionDialog(Thinlet thinlet, Throwable throwable) { 15 try { 16 Object dialog = thinlet.parse("/thinlet/drafts/exceptiondialog.xml", this); 17 thinlet.setString(dialog, "text", throwable.getClass().getName()); 18 thinlet.setString(thinlet.find(dialog, "message"), "text", throwable.getMessage()); 19 StringWriter stacktrace = new StringWriter(); 20 throwable.printStackTrace(new PrintWriter(stacktrace)); 21 thinlet.setString(thinlet.find(dialog, "stacktrace"), "text", 22 stacktrace.toString().replace('\r', ' ').replace('\t', ' ')); 23 thinlet.add(dialog); 24 } catch (Exception exc) { exc.printStackTrace(); } 25 } 26 27 30 public void close(Thinlet thinlet, Object dialog) { 31 thinlet.remove(dialog); 32 } 33 } | Popular Tags |