List of usage examples for java.lang Throwable Throwable
public Throwable(Throwable cause)
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Throwable("from java2s.com"); System.out.println(t.toString()); }
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Exception("from java2s.com"); t.initCause(new Throwable("")); }
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Exception("from java2s.com"); t.addSuppressed(new Throwable("from java2s.com")); }
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Exception("from java2s.com"); Throwable tNew = new Throwable(t); }
From source file:Test.java
public static void main(String[] args) { try {/*www. j a v a 2 s .com*/ System.out.print("Enter a number: "); int number = 100; if (number < 0) { throw new InvalidParameter(); } if (number > 10) { throw new AssertionError("Number was too big", new Throwable("Throwable assertion message")); } } catch (InputMismatchException | InvalidParameter e) { e.addSuppressed(new Throwable()); System.out.println("Invalid input, try again"); } catch (final Exception e) { System.out.println("Invalid input, try again"); } }
From source file:Main.java
private static Throwable invalidInt(String s) throws Throwable { throw new Throwable("Invalid int: \"" + s + "\""); }
From source file:Main.java
public static String getCurrentThreadStack() { StringWriter sw = new StringWriter(); new Throwable("").printStackTrace(new PrintWriter(sw)); return "\n" + sw.toString(); }
From source file:Main.java
public static long parseLong(String string, int radix) throws Throwable { if (radix >= 2 && radix <= 36) { if (string == null) { throw new Throwable("Invalid long: \"" + string + "\""); } else {// w w w.ja v a2s . c om int length = string.length(); int i = 0; if (length == 0) { throw new Throwable("Invalid long: \"" + string + "\""); } else { boolean negative = string.charAt(i) == 45; if (negative) { ++i; if (i == length) { throw new Throwable("Invalid long: \"" + string + "\""); } } return parseLong(string, i, radix, negative); } } } else { throw new Throwable("Invalid radix: " + radix); } }
From source file:com.moss.greenshell.wizard.catastrophe.PostMortemScreen.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setLayout(new BorderLayout()); frame.setSize(800, 600);// w w w . j av a 2 s .co m final PostMortemScreen postMortemScreen = new PostMortemScreen( new Throwable("Just testing the PostMortemScreen")); final ProgressMonitorScreen progress = new ProgressMonitorScreen("Waiting for something to fail."); ProcessPanel processPanel = new ProcessPanel(progress); // postMortemScreen.setEnvironment(processPanel); frame.add(processPanel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); new Thread() { @Override public void run() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } progress.done(postMortemScreen); } }.start(); }
From source file:Main.java
/** * @param thread a thread// w w w. j a v a 2 s . c om * @return a human-readable representation of the thread's stack trace */ public static String formatStackTrace(Thread thread) { Throwable t = new Throwable( String.format("Stack trace for thread %s (State: %s):", thread.getName(), thread.getState())); t.setStackTrace(thread.getStackTrace()); StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); return sw.toString(); }