Gets a stack trace where this exception occured.

@return a stack trace as a string.
486354
@JsonProperty("stack_trace")
	public String getStackTraceString() {
		if (_stackTrace != null)
			return _stackTrace;

		StackTraceElement[] ste = getStackTrace();
		StringBuilder builder = new StringBuilder();
		if (ste != null) {
			for (int i = 0; i < ste.length; i++) {
				if (builder.length() > 0)
					builder.append(" ");
				builder.append(ste[i].toString());
			}
		}
		return builder.toString();
	}
353596
public String getStack()
    {
        if (_string==null)
        {
            StringBuffer buf= new StringBuffer(512);
            
            for (int i=0;i<_stack.length;i++)
            {
                if (i>_top)
                    buf.append(__lineSeparator);
                buf.append(_stack[i].toString());
            }
            _string=buf.toString();
        }
        
        return _string;
    }
255255
public function getBetterTrace() {
        $trace = $this->betterTrace;

        if (!$trace) {
            // transform the original stacktrace into a better one
            $trace = DebugHelper::fixTrace($this->getTrace(), $this->getFile(), $this->getLine());

            // drop the first frame if the exception was created in the registered error handler
            if (DebugHelper::getFQFunctionName($trace[0]) == ErrorHandler::class.'::handleError') {
                \array_shift($trace);

                // if the error was triggered by include/require/_once: fix the next frame, it's wrong
                if (sizeof($trace) > 1) {
                    $function = DebugHelper::getFQFunctionName($trace[0]);
                    if ($function=='include' || $function=='include_once' || $function=='require' || $function=='require_once') {
                        if (isset($trace[0]['file']) && isset($trace[1]['file'])) {
                            if ($trace[0]['file'] == $trace[1]['file']) {
                                if (isset($trace[0]['line']) && isset($trace[1]['line'])) {
                                    if ($trace[0]['line'] == $trace[1]['line']) {
                                        unset($trace[0]['file'], $trace[0]['line']);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // store the new stacktrace
            $this->betterTrace = $trace;
        }
        return $trace;
    }
1078287
public function getStackTrace()
    {
        if (!isset($this->message[4]) || empty($this->message[4])) {
            return null;
        }

        $traces = array_map(function ($trace) {
            return "in {$trace['file']}:{$trace['line']}";
        }, $this->message[4]);
        return implode("\n", $traces);
    }
784240
public String getMessage() {
	StringBuffer buf = new StringBuffer();
	if (code != UNSPECIFIED) {
	    buf.append(getCodeExplanation(code));
	}
	if (customMessage != null) {
	    buf.append(" Custom message: ");
	    buf.append(customMessage);
	}
	if (code != UNSPECIFIED) {
	    buf.append(" (error code ").append(String.valueOf(code)).append(")");
	}
	if (cause != null) {
	    buf.append(" [Nested exception message: ");
	    buf.append(cause.getMessage());
	    buf.append("]");
	}
	return buf.toString();
    }
12514
static ExceptionInfo processStackTrace(StackTrace exception) {
    if (exception == null) {
      return null;
    }
    // Escape any special HTML characters in the exception that would otherwise break the HTML
    // rendering (e.g. the angle brackets around the default toString() for enums).
    String message = StringEscapeUtils.escapeHtml4(exception.toString());

    // Newline characters are usually stripped out by the parsing code in
    // {@link StackTrace#from(String)}, but they can sometimes remain (e.g. when the stack trace
    // is not in an expected format).  This replacement needs to be done after any HTML escaping.
    message = message.replace("\n", "<br/>");

    List<String> lines = exception.getElements()
        .stream()
        .map(element -> "&nbsp;&nbsp;&nbsp;&nbsp;at " + element.toString())
        .collect(toList());
    while (exception.getCause() != null) {
      exception = exception.getCause();
      String causeMessage = StringEscapeUtils.escapeHtml4(exception.toString());
      lines.add("Caused by: " + causeMessage.replace("\n", "<br/>"));
    }
    return new ExceptionInfo(message, lines);
  }
912804
public static String getCallerClass() {
		StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
		if (stacktrace.length >= 4) {
			StackTraceElement element = stacktrace[3];
			return element.getClassName();
		} else {
			return StringUtils.EMPTY;
		}
	}
819124
public static String getExceptionCause(final Exception exception) {
		if (exception == null) {
			return "";
		}

		final StringBuilder cause = new StringBuilder();
		Throwable nestedException = (Throwable) exception;
		while (nestedException != null) {
			cause.append("Caused by: ").append(nestedException.toString()).append(" ");
			nestedException = getInnerException(nestedException);
		}

		return cause.toString();
	}
1364696
public static String stackTraceToString(Throwable cause) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream pout = new PrintStream(out);
        cause.printStackTrace(pout);
        pout.flush();
        try {
            return new String(out.toByteArray());
        } finally {
            try {
                out.close();
            } catch (IOException ignore) {
                // ignore as should never happen
            }
        }
    }
978256
public static String oneLiner(Throwable thrown)
  {
    StackTraceElement[] stack = thrown.getStackTrace();
    String topOfStack = null;
    if (stack.length > 0)
    {
      topOfStack = " at " + stack[0];
    }
    return thrown.toString() + topOfStack;
  }
675195
public static String getCallerMethod()
  {
    StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
    if(stackTrace.length == 0) {
      return "unknown";
    }
    final StackTraceElement e = stackTrace[0];
    return Strings.concat(e.getClassName(), '#', e.getMethodName(), ':', e.getLineNumber());
  }
1111455
public static String dumpStack(final Throwable cause) {
        if (cause == null) {
            return "Throwable was null";
        }
        final StringWriter sw = new StringWriter();
        final PrintWriter s = new PrintWriter(sw);

        // This is very close to what Thread.dumpStack does.
        cause.printStackTrace(s);

        final String stack = sw.toString();
        try {
            sw.close();
        } catch (final IOException e) {
            LOG.warn("Could not close writer", e);
        }
        s.close();
        return stack;
    }
1137526
public static String getCallerMethod() {
		StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
		if (stacktrace.length >= 4) {
			StackTraceElement element = stacktrace[3];
			return element.getClassName() + '.' + element.getMethodName() + "()";
		} else {
			return StringUtils.EMPTY;
		}
	}
444887
private static StackTraceElement getStackTrace() {
    StackTraceElement[] stack = Thread.currentThread().getStackTrace();

    int i = 2; // we can skip the first two (first is getStackTrace(), second is this method)
    while (i < stack.length) {
      boolean isLoggingClass = false;
      for (String loggingClass : loggingClasses) {
        String className = stack[i].getClassName();
        if (className.startsWith(loggingClass)) {
          isLoggingClass = true;
          break;
        }
      }
      if (!isLoggingClass) {
        break;
      }

      i += 1;
    }

    // if we didn't find anything, keep last element (probably shouldn't happen, but could if people add too many logging classes)
    if (i >= stack.length) {
      i = stack.length - 1;
    }
    return stack[i];
  }
207283
protected static String getStackTrace(final Throwable cause) {
    if (cause == null) {
      return null;
    } else {
      final StringWriter writer = new StringWriter();
      cause.printStackTrace(new PrintWriter(writer));
      return writer.toString();
    }
  }
914215
private static String[] getCallStackFromStackTraceElement(StackTraceElement[] exceptionCallStack) {
        if (exceptionCallStack == null)
            return null;

        String[] answer = new String[exceptionCallStack.length];
        for (int i = 0; i < exceptionCallStack.length; i++) {
            answer[exceptionCallStack.length - 1 - i] = exceptionCallStack[i].getClassName();
        }
        return answer;
    }
1218569
public static StackTraceElement getCallerStackTraceElement () {
		StackTraceElement callerStackTraceElement = null;

		StackTraceElement[] stackTraceElements = Thread.currentThread ().getStackTrace ();
		if (stackTraceElements != null) {
			if (stackTraceElements.length > 3) {
				callerStackTraceElement = stackTraceElements[3];
			}
		}

		return callerStackTraceElement;
	}