All Downloads are FREE. Search and download functionalities are using the official Maven repository.

x7.core.util.ExceptionUtil Maven / Gradle / Ivy

There is a newer version: 2.2.7.RELEASE
Show newest version
package x7.core.util;

public class ExceptionUtil {

    public static String getMessage(Exception e){
        String msg = "";
        StackTraceElement[] eleArr = e.getStackTrace();
        int length = eleArr.length;
        if (eleArr != null && length > 0){
            msg = eleArr[0].toString();
            if (length > 1){
                msg += "\n";
                msg += eleArr[1].toString();
            }
        }

        return msg;
    }

    public static String getMessage(Throwable e){
        String msg = "";
        StackTraceElement[] eleArr = e.getStackTrace();
        int length = eleArr.length;
        if (eleArr != null && length > 0){
            msg = eleArr[0].toString();
            if (length > 1){
                msg += "\n";
                msg += eleArr[1].toString();
            }
        }

        return msg;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy