Exception转化为 String

   if (exception != null) {
            StringWriter stringWriter = new StringWriter();
            PrintWriter pw = new PrintWriter(stringWriter);
            exception.printStackTrace(pw);

            String errorStack = stringWriter.toString();
            errorStack = errorStack.substring(0, 1000);

            extend.put("errorStack", errorStack);
        }

 

你可能感兴趣的:(程序员之路)