StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw, true)); String error = sw.toString();