Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,14 @@ public void testExceptionStacktrace() {
assertTrue(out.contains("at org.apache.camel.language."));
}

@Test
public void testExceptionStacktraceNoException() {
// CAMEL-24651
String out = context.resolveLanguage("simple").createExpression("${exception.stacktrace}").evaluate(exchange,
String.class);
assertNull(out);
}

@Test
public void testException() {
exchange.setException(new IllegalArgumentException("Just testing"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ private ExceptionHelper() {
* Dumps the stack trace from the given exception to a String
*
* @param e the exception to print the stack trace
* @return A string instance with the stack trace for the given exception
* @return A string instance with the stack trace for the given exception, or null if the exception is null
*/
public static String stackTraceToString(Throwable e) {
if (e == null) {
return null;
}
final StringWriter writer = new StringWriter();
final PrintWriter printWriter = new PrintWriter(writer, true);
e.printStackTrace(printWriter);
Expand Down