returns the formatted stacktrace of the exception `e`.

    :param BaseException e: an exception to format into str
    :rtype: str
352559
def error2str(e):
    
    out = StringIO()
    traceback.print_exception(None, e, e.__traceback__, file=out)
    out.seek(0)
    return out.read()
929200
public static String toShortString(Throwable e, int stackLevel) {
        StackTraceElement[] traces = e.getStackTrace();
        StringBuilder sb = new StringBuilder(1024);
        sb.append(e.toString()).append("\t");
        if (traces != null) {
            for (int i = 0; i < traces.length; i++) {
                if (i < stackLevel) {
                    sb.append("\tat ").append(traces[i]).append("\t");
                } else {
                    break;
                }
            }
        }
        return sb.toString();
    }
980831
public static String getExceptionMessage(Exception e) {
        if (e.getCause() != null && e.getCause().getMessage() != null) {
            String s = getscard(e.getCause().getMessage());
            if (s != null)
                return s;
        }
        if (e.getMessage() != null) {
            String s = getscard(e.getMessage());
            if (s != null)
                return s;
        }
        return e.getMessage();
    }
1114005
private String getStackTrace(AbstractEngineException data) {
        try (StringBuilderWriter writer = new StringBuilderWriter()) {
            data.printStackTrace(new PrintWriter(writer));
            return writer.getBuilder().toString();
        }
    }
1243451
private void setStackTrace(Throwable e) {
        // Convert stack trace to a String
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        stackTrace = sw.toString();
        setLineSeparator(getLineSeparatorProperty());
    }
211499
def excinfo(e):
    '''
    
    '''
    tb = sys.exc_info()[2]
    path, line, name, sorc = traceback.extract_tb(tb)[-1]
    ret = {
        'err': e.__class__.__name__,
        'errmsg': str(e),
        'errfile': path,
        'errline': line,
    }

    if isinstance(e, s_exc.SynErr):
        ret['errinfo'] = e.errinfo

    return ret
35357
public static String stackToDebugString(Throwable e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        pw.close();
        String text = sw.toString();
        
        // Jump past the throwable
        text = text.substring(text.indexOf("at"));
        return text;
    }
1124858
public static String getMessage(PyException e) {
        if (e.getMessage() != null) {
            return e.getMessage();
        } else {
            StringWriter stringWriter = new StringWriter();
            e.printStackTrace(new PrintWriter(stringWriter));
            return stringWriter.toString();
        }
    }
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];
		
	}
720929
def api_exception(e):
    
    _, _, exc_traceback = sys.exc_info()
    tb = '\n'.join(traceback.format_tb(exc_traceback))
    return {
        400: BadRequestError,
        401: UnauthorizedError,
        403: ForbiddenError,
        404: NotFoundError,
        405: MethodNotAllowedError,
        409: ConflictError,
        410: GoneError,
        422: UnprocessibleEntityError,
        429: TooManyRequestsError,
        500: InternalServerError,
        503: ServiceUnavailableError,
        504: ServerTimeoutError,
    }.get(e.status, DynamicApiError)(e, tb)
808801
public static void printFullStackTrace(PrintWriter out, ServletException e)
    {
        // determine the absolute root exception
        Throwable th = null;

        while (e != null)
        {
            th = e.getRootCause();

            if (th == null)
            {
                th = e;
                break;
            }
            else
                e = th instanceof ServletException ? (ServletException)th : null;
        }

        // now print the root exception
        try
        {
            // if th is a ServletErrorReport, it's already encoded...if not, encode it
            if (th instanceof ServletErrorReport)
                out.println("<HR width=\"100%\">\n" + th.getMessage() + "<BR>");
            else
                out.println("<HR width=\"100%\">\n" + encodeChars(th.getMessage())+ "<BR>");

            // print the stack trace to a string writer so we can encode it if necessary and format
            // its output
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            th.printStackTrace(pw);
            pw.flush();
            String traceOut;

            // if it's a ServletErrorReport, it's already encoded...if not, encode it
            if (th instanceof ServletErrorReport)
                traceOut = sw.toString();
            else
                traceOut = encodeChars(sw.toString());

            // split the stack lines so they'll appear right in the browser
            StringTokenizer st = new StringTokenizer(traceOut, "\n");

            while (st.hasMoreTokens())
            {
                out.println(st.nextToken());
                out.println("<BR>&nbsp;&nbsp;&nbsp;&nbsp;");
            }

            out.println("<BR>");
        }
        catch (EmptyStackException ex)
        {
          com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(ex, "com.ibm.ws.webcontainer.servlet.DefaultErrorReporter.printFullStackTrace", "158");
        }
    }
707481
function stackTrace(e) {

    var trace = [];

    // Remove node.js trace pollutants:
    var stack = (e.stack || e.stacktrace).replace(/at Module._compile \(module\.js:\d+:\d+\)[\s\S]+$/, '');

    var match;
    var regex = /(?:at (?!<)(?:.+?\()?|@).*?(.+?):(\d+)(?=:\d+)?/g;

    while (match = regex.exec(stack)) {
      trace.push({
        file: match[1],
        line: +match[2]
      });
    }

    return trace;

  }
1031035
def on_Exception(self, e):
        

        if logging.getLogger(self.LOGGER_NAME).level == logging.DEBUG:
            import traceback

            traceback.print_exception(*sys.exc_info())
        else:
            from PyQt5 import QtCore

            sys.stderr.write("""An unexpected error occurred.
Check that you are using the latest version of PyQt5 and send an error report to
support@riverbankcomputing.com, including the following information:

  * your version of PyQt (%s)
  * the UI file that caused this error
  * the debug output of pyuic5 (use the -d flag when calling pyuic5)
""" % QtCore.PYQT_VERSION_STR)
409408
private String getStackTrace(AbstractRestException data) {
        StringBuilderWriter writer = new StringBuilderWriter();
        try {
            data.printStackTrace(new PrintWriter(writer));
            return writer.getBuilder().toString();
        } finally {
            writer.close();
        }
    }
791796
public void printStackTrace(Throwable e, PrintWriter os)
  {
    CharArrayWriter writer = new CharArrayWriter();
    PrintWriter pw = new PrintWriter(writer);
    
    e.printStackTrace(pw);

    pw.close();
    char []array = writer.toCharArray();

    CharBuffer cb = filter(array);

    if (os != null)
      os.print(cb.toString());
    else
      System.out.println(cb);
  }
208181
def handle_error(self, e):
        
        got_request_exception.send(current_app._get_current_object(), exception=e)

        if not isinstance(e, HTTPException) and current_app.propagate_exceptions:
            exc_type, exc_value, tb = sys.exc_info()
            if exc_value is e:
                raise
            else:
                raise e

        headers = Headers()
        if isinstance(e, HTTPException):
            code = e.code
            default_data = {
                'message': getattr(e, 'description', http_status_message(code))
            }
            headers = e.get_response().headers
        else:
            code = 500
            default_data = {
                'message': http_status_message(code),
            }

        # Werkzeug exceptions generate a content-length header which is added
        # to the response in addition to the actual content-length header
        # https://github.com/flask-restful/flask-restful/issues/534
        remove_headers = ('Content-Length',)

        for header in remove_headers:
            headers.pop(header, None)

        data = getattr(e, 'data', default_data)

        if code and code >= 500:
            exc_info = sys.exc_info()
            if exc_info[1] is None:
                exc_info = None
            current_app.log_exception(exc_info)

        error_cls_name = type(e).__name__
        if error_cls_name in self.errors:
            custom_data = self.errors.get(error_cls_name, {})
            code = custom_data.get('status', 500)
            data.update(custom_data)

        if code == 406 and self.default_mediatype is None:
            # if we are handling NotAcceptable (406), make sure that
            # make_response uses a representation we support as the
            # default mediatype (so that make_response doesn't throw
            # another NotAcceptable error).
            supported_mediatypes = list(self.representations.keys())
            fallback_mediatype = supported_mediatypes[0] if supported_mediatypes else "text/plain"
            resp = self.make_response(
                data,
                code,
                headers,
                fallback_mediatype = fallback_mediatype
            )
        else:
            resp = self.make_response(data, code, headers)

        if code == 401:
            resp = self.unauthorized(resp)
        return resp
387607
def exception_format():
    
    return "".join(traceback.format_exception(
        sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]
    ))