Get exception information in Java
During development, we may need to record exception information to other places, and we can use the following code to output exception information
public static String getExceptionMessage(Throwable e) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter, true);
e.printStackTrace(printWriter);
printWriter.flush();
stringWriter.flush();
return stringWriter.toString();
}