package com.doctor.commons;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

import com.doctor.beaver.annotation.ThreadSafe;

/**
 * @author sdcuike
 *         <p>
 *         Created on 2016年9月27日<br/>
 */
@ThreadSafe
public final class ExceptionUtils {

    public static String printStackTraceToString(final Throwable t) throws IOException {
        try (StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);) {
            t.printStackTrace(pw);
            pw.flush();
            sw.flush();
            return sw.toString();
        }
    }

    public static String printFullStackTraceToString(final Throwable t) throws IOException {
        try (StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);) {
            Throwable caseT = t;
            while (caseT != null) {
                caseT.printStackTrace(pw);
                caseT = caseT.getCause();
            }
            pw.flush();
            sw.flush();
            return sw.toString();
        }
    }

}

@@ -1085,10 +1085,697 @@
 %0A    %7D%0A%0A
+    /**%0A     * %E5%88%A4%E6%96%AD%E5%BC%82%E5%B8%B8%E6%98%AF%E5%90%A6%E6%98%AF%E9%9D%9E%E5%8F%97%E6%A3%80%E5%BC%82%E5%B8%B8%E3%80%82%E5%85%B7%E4%BD%93%E6%9F%A5%E7%9C%8B java doc %7B@link Error%7D%E4%B8%8E%7B@link RuntimeException%7D%0A     * %0A     * @param ex%0A     * @return %7B@code boolean%7D%0A     * @see java.lang.Exception%0A     * @see java.lang.RuntimeException%0A     * @see java.lang.Error%0A     */%0A    public static boolean isUnCheckedException(Throwable ex) %7B%0A        return (ex instanceof Error %7C%7C ex instanceof RuntimeException);%0A    %7D%0A%0A    /**%0A     * %E5%88%A4%E6%96%AD%E5%BC%82%E5%B8%B8%E6%98%AF%E5%90%A6%E6%97%B6%E5%80%99%E5%8F%97%E6%A3%80%E5%BC%82%E5%B8%B8%0A     * %0A     * @param ex%0A     * @return %7B@code boolean%7D%0A     * @see java.lang.Exception%0A     * @see java.lang.RuntimeException%0A     * @see java.lang.Error%0A     */%0A    public static boolean isCheckedException(Throwable ex) %7B%0A        return !isUnCheckedException(ex);%0A    %7D%0A%0A
 %7D%0A

add 判断异常是否是非受检异常与非