Java examples for java.lang:Exception
Function used to get the error trace from the exception object
//package com.java2s; public class Main { /**//from www. j ava2 s . c om * Function used to get the error trace from the exception object * @param e * @return * @throws Exception */ public static String stackTraceToString(Throwable e) { StringBuilder sb = new StringBuilder(); try { for (StackTraceElement element : e.getStackTrace()) { sb.append(element.toString()); sb.append("\n"); } } catch (Exception ex) { ex.printStackTrace(); } return sb.toString(); } }