Retrieves stack trace from throwable.

@param t
@param depth
@return
552500
public static String getRootStackTrace(Throwable t, int depth) {

		while(t.getCause() != null) {
			t = t.getCause();
		}
		return getStackTrace(t, depth, null);
	}
863719
public static Throwable getRootCause(Throwable t) {
        if (t == null) {
            return null;
        }
        while (t.getCause() != null) {
            t = t.getCause();
        }
        return t;
    }
977800
@SuppressWarnings("deprecation")
    protected Throwable getNestedException(Throwable t) {
        Throwable root = t;
        for (;;) {
            if (root instanceof RemoteException) {
                RemoteException re = (RemoteException) root;
                if (re.detail == null)
                    break;
                root = re.detail;
            } else if (root instanceof NamingException) {
                NamingException ne = (NamingException) root;
                if (ne.getRootCause() == null)
                    break;
                root = ne.getRootCause();
            } else if (root instanceof com.ibm.ws.exception.WsNestedException) { //d121522
                com.ibm.ws.exception.WsNestedException ne = (com.ibm.ws.exception.WsNestedException) root;
                if (ne.getCause() == null)
                    break;
                root = ne.getCause();
            } else {
                break;
            }
        }
        return root;
    }
912629
public static <T extends Throwable> T clearTrace(T exception) {
        requireNonNull(exception, "exception");
        exception.setStackTrace(EMPTY_STACK_TRACE);
        return exception;
    }
718319
public static String getStackTrace(Throwable throwable, boolean isHtmlStyle) {
        AssertHelper.notNull(throwable, "throwable can't be null.");
        String line = isHtmlStyle ? "<br/>" : "\r\n";
        String tab = isHtmlStyle ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
        while (throwable instanceof NiubiException) {
            throwable = throwable.getCause();
        }
        StringBuffer stringBuffer = new StringBuffer(throwable.getClass().getName()).append(":");
        if (throwable.getMessage() != null) {
            stringBuffer.append(throwable.getMessage()).append(line);
        } else {
            stringBuffer.append(line);
        }
        try {
            StackTraceElement[] stackElements = throwable.getStackTrace();
            if (stackElements != null) {
                for (int i = 0; i < stackElements.length && i < MAX_STACK_TRACE_DEEP; i++) {
                    stringBuffer.append(tab);
                    stringBuffer.append(stackElements[i].getClassName()).append('.');
                    stringBuffer.append(stackElements[i].getMethodName()).append('(');
                    stringBuffer.append(stackElements[i].getFileName()).append(':');
                    stringBuffer.append(stackElements[i].getLineNumber()).append(')');
                    stringBuffer.append(line);
                }
            }
        } catch (Exception e) {
            //ignored
        }
        if (isHtmlStyle) {
            return stringBuffer.length() > MAX_LENGTH ? (stringBuffer.substring(0, stringBuffer.lastIndexOf(line)) + DEFAULT_END_STRING) : stringBuffer.toString();
        } else {
            return stringBuffer.length() > MAX_LENGTH ? (stringBuffer.substring(0, MAX_LENGTH) + DEFAULT_END_STRING) : stringBuffer.toString();
        }
    }
831010
public static Throwable unwrap(Throwable t) {
        for (;;) {
            if (t == null)
                throw new NullPointerException();

            if (t instanceof java.util.concurrent.ExecutionException)
                t = t.getCause();
            else if (t instanceof java.lang.reflect.InvocationTargetException)
                t = t.getCause();
            else if (t.getClass().equals(RuntimeException.class) && t.getCause() != null)
                t = t.getCause();
            else
                return t;
        }
    }
1356307
private synchronized void logThrowable(final Level level,
			final String message, final Throwable t)
	{

		if (t != null) {
			log("\r\n[" + System.currentTimeMillis() + "]\t" + message);
			log("\r\n" + t);
			log("\r\n");

			for (StackTraceElement st : t.getStackTrace()) {
				log("\t" + st.toString() + "\r\n");
			}

			Throwable c = t.getCause();
			if (c != null) {

				log("Caused by:\t" + c + "\r\n");

				for (StackTraceElement st : c.getStackTrace()) {
					log("\t" + st.toString() + "\r\n");
				}
			}

			log("\r\n");
			this.flush();
		}
	}
133296
private List<String> getStackTrace(Object error) {
        if (fullStack && error instanceof Throwable) {
            List<String> stackTrace = new ArrayList<>();
            for (StackTraceElement t : ((Throwable) error).getStackTrace()) {
                stackTrace.add(t.toString());
            }
            return stackTrace;
        } else {
            return Collections.emptyList();
        }
    }
1144468
public static StackTraceElement determineCauseStackTraceElementsn(Throwable e)
	{
		
		if(e.getCause() != null)
			return determineCauseStackTraceElementsn(e.getCause());
		
		StackTraceElement[] stackTraceElements = e.getStackTrace();
		
		if(stackTraceElements == null || stackTraceElements.length == 0)
			return null;

		
		return stackTraceElements[0];
		
	}
451712
public String getStackTraceInfo(Throwable aThrowable) {
        final Writer localWriter = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(localWriter);
        aThrowable.printStackTrace(printWriter);
        return localWriter.toString();
    }
950869
public static Stack getStack() {
        Stack stack = interceptionContexts.get();
        if (stack == null) {
            stack = new Stack(interceptionContexts);
            interceptionContexts.set(stack);
        }
        return stack;
    }
1074031
public String getStack() {
		if (stackTrace == null) {
			if (stack == null) {
				StringWriter sw = new StringWriter(512);
				PrintWriter pw = new PrintWriter(sw, true);
				super.printStackTrace(pw);
				stackTrace = sw.toString().trim();
			} else {
				stackTrace = stack.trim();
			}
		}
		return stackTrace;
	}
631432
@Override
    public void trace(String msg, Throwable t) {
        logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, msg, t);
    }
1022060
public static String getStackTrace(Throwable t, String separator) {

        Throwable cause = t;
        String result = "";
        while (cause != null) {
            result += getStackTraceAsString(cause.getStackTrace(), separator);
            cause = cause.getCause();
        }
        return result;
    }
865101
public <T extends Throwable> T throwing(Level level, T throwable) {
        if (instanceofLAL) {
            ((LocationAwareLogger) logger).log(THROWING_MARKER, FQCN, level.level, "throwing", null, throwable);
        }
        return throwable;
    }
168456
private static String __getStackTrace(Throwable throwable) {
        StringWriter stringWriter = new StringWriter();
        throwable.printStackTrace(new PrintWriter(stringWriter));

        return stringWriter.toString();
    }
383285
private static StackTraceElement findStackTraceElement(Throwable t) {
       StackTraceElement element = t.getStackTrace().length > 0 ? t.getStackTrace()[0] : null;
       int index = 0;
        String chorusAssertClassName = ChorusAssert.class.getName();
        String junitAssertClassName = "org.junit.Assert";  //junit may not be in classpath so don't use Assert.class.getName()
        String junitLegacyClassName = "junit.framework.Assert";  //need to support alternative (legacy?) junit 3 style Assert
        while ( element != null && (
                element.getClassName().contains(chorusAssertClassName) ||
                element.getClassName().contains(junitAssertClassName) ||
                element.getClassName().contains(junitLegacyClassName))
            ) {
           index += 1;
           element = t.getStackTrace().length > index ? t.getStackTrace()[index] : null;
       }
       return element;
    }