List of usage examples for java.lang IllegalStateException setStackTrace
public void setStackTrace(StackTraceElement[] stackTrace)
From source file:com.aliasi.lingmed.medline.DownloadMedline.java
/** * Main method to be called from the command-line. * * @param args Command-line arguments./*from www . j a v a 2s . co m*/ */ public static void main(String[] args) throws Exception { DownloadMedline downloader = new DownloadMedline(args); while (true) { try { // Logger.getLogger(DownloadMedline.class).info("Run downloader"); downloader.run(); // Logger.getLogger(DownloadMedline.class).info("Run completed"); } catch (Exception e) { String msg = "Unexpected exception=" + e; // Logger.getLogger(DownloadMedline.class).warn(msg); IllegalStateException e2 = new IllegalStateException(msg); e2.setStackTrace(e.getStackTrace()); throw e2; } if (downloader.sleepMins() < 1) break; Thread.sleep(downloader.sleepMins() * MINUTE); } }
From source file:org.bug4j.client.Bug4jTest.java
@Test public void testForceNew() throws Exception { final IllegalStateException e = new IllegalStateException("oh, c 'est d\u00e9j\u00e0 cass\u00e9?"); e.setStackTrace(new StackTraceElement[] { new StackTraceElement("org.bug4j.SomeClass", buildRandomMethodName(), "SomeClass.java", (int) (Math.random() * 10000)), new StackTraceElement("org.bug4j.SomeClass", buildRandomMethodName(), "SomeClass.java", (int) (Math.random() * 10000)), new StackTraceElement("org.bug4j.SomeClass", buildRandomMethodName(), "SomeClass.java", (int) (Math.random() * 10000)), new StackTraceElement("org.bug4j.SomeClass", buildRandomMethodName(), "SomeClass.java", (int) (Math.random() * 10000)), new StackTraceElement("org.bug4j.SomeClass", buildRandomMethodName(), "SomeClass.java", (int) (Math.random() * 10000)), new StackTraceElement("org.bug4j.SomeClass", buildRandomMethodName(), "SomeClass.java", (int) (Math.random() * 10000)), new StackTraceElement("org.bug4j.SomeClass", buildRandomMethodName(), "SomeClass.java", (int) (Math.random() * 10000)), new StackTraceElement("org.bug4j.SomeClass", buildRandomMethodName(), "SomeClass.java", (int) (Math.random() * 10000)) }); Bug4jAgent.report("Forcing a new exception", e); Bug4jAgent.shutdown();/* w w w.j a va2 s. c o m*/ Assert.assertEquals(1, Bug4jAgent.getReported()); }
From source file:org.bug4j.client.Bug4jTest.java
@Test public void testSameTitle() throws Exception { final Random random = new Random(); {// w ww . j av a 2 s . com final IllegalStateException e = new IllegalStateException("SameTitle"); e.setStackTrace(new StackTraceElement[] { new StackTraceElement("org.bug4j.SomeClass", "someMethod", "SomeClass.java", 100), new StackTraceElement("org.bug4j.SomeClass", "someMethod", "SomeClass.java", random.nextInt()), new StackTraceElement("org.bug4j.SomeClass", "someMethod", "SomeClass.java", random.nextInt()), new StackTraceElement("org.bug4j.SomeClass", "someMethod", "SomeClass.java", random.nextInt()), }); Bug4jAgent.report("testSameTitle", e); } { final IllegalStateException e = new IllegalStateException("SameTitle"); e.setStackTrace(new StackTraceElement[] { new StackTraceElement("org.bug4j.SomeClass", "someMethod", "SomeClass.java", 100), new StackTraceElement("org.bug4j.someOtherClass", "someOtherMethod", "SomeClass.java", random.nextInt()), new StackTraceElement("org.bug4j.someOtherClass", "someOtherMethod", "SomeClass.java", random.nextInt()), new StackTraceElement("org.bug4j.someOtherClass", "someMethod", "SomeClass.java", random.nextInt()), }); Bug4jAgent.report("testSameTitle", e); } Bug4jAgent.shutdown(); Assert.assertEquals(2, Bug4jAgent.getReported()); }
From source file:org.bug4j.client.Bug4jTest.java
/** * Verifies that we don't report the same error twice *//* w w w .j a v a2 s . c o m*/ @Test public void testNoReReport() throws Exception { { final IllegalStateException e = new IllegalStateException("SameTitle"); e.setStackTrace(new StackTraceElement[] { new StackTraceElement("org.bug4j.SomeClass", "testSameTitle", "SomeClass.java", 100), new StackTraceElement("org.bug4j.SomeClass", "testSameTitle", "SomeClass.java", 200), new StackTraceElement("org.bug4j.SomeClass", "testSameTitle", "SomeClass.java", 300), new StackTraceElement("org.bug4j.SomeClass", "testSameTitle", "SomeClass.java", 400), }); for (int i = 0; i < 10; i++) { Bug4jAgent.report("testSameTitle", e); } } Bug4jAgent.shutdown(); Assert.assertEquals(1, Bug4jAgent.getReported()); }