Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.PrintWriter; import java.io.StringWriter; public class Main { /** * This return exception as string. * * @param throwable Throwable * @return exception string */ public static String exceptionToString(Throwable throwable) { StringWriter errors = new StringWriter(); throwable.printStackTrace(new PrintWriter(errors)); return errors.toString(); } }