Created
August 20, 2015 19:09
-
-
Save ranjitiyer/02078f1e5bb30ccdfddd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExceptionUtils { | |
public static String stackTraceAsString(Exception ex) { | |
if (ex == null) { | |
return ""; | |
} | |
return Arrays.asList(ex.getStackTrace()) | |
.stream() | |
.reduce( | |
new StringBuilder(), | |
(builder, frame) -> { | |
builder.append(frame.toString()); | |
return builder; | |
}, | |
(b1, b2) -> { | |
return new StringBuilder(b1.toString() + "\n" + b2.toString()); | |
}) | |
.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment