DefaultRuntimeErrorCallback { protected static String extractMessageRecursively(final Throwable t) { if (t == null) { return ""; } if (t.getCause() == null) { return t.getMessage(); } return t.getMessage() + " Caused by: " + extractMessageRecursively(t.getCause()); }  void error(final Throwable throwable); void unlock(); static final String PARSING_JSON_SYNTAX_MSG; static final String PARSING_JSON_MSG; static final String SCRIPT_ERROR_MSG; }
@Test public void testExtractMessageRecursively() { Exception cause = new Exception("CAUSE"); Exception intermediary = new Exception("INTERMEDIARY", cause); Exception e = new Exception("FIRST", intermediary); String message = DefaultRuntimeErrorCallback.extractMessageRecursively(e); assertEquals("FIRST Caused by: INTERMEDIARY Caused by: CAUSE", message); String MESSAGE = "Message"; message = extractMessageRecursively(new Exception(MESSAGE)); assertEquals(MESSAGE, message); assertEquals("", extractMessageRecursively(null)); }