zoukankan      html  css  js  c++  java
  • Java之ExceptionHelper工具类

    
    import java.util.Map;
    
    import org.apache.commons.lang3.StringUtils;
    import org.apache.commons.lang3.exception.ExceptionUtils;
    
    
    public class ExceptionHelper {
        public static String getFullStackTrace(Throwable t){
            if(t==null)return "";
            String expStr = "";
            if(t instanceof SystemException){
                expStr +=  getSystemExceptionMsg((SystemException)t);
            }
            expStr += StringUtils.join(ExceptionUtils.getRootCauseStackTrace(t),"
    ");
            return expStr;
        }
    
        private static String getSystemExceptionMsg(SystemException exp) { 
            if(exp==null)return "";
            StringBuilder sb = new StringBuilder();
            ErrorCode errorCode =exp.getErrorCode();
            Map<String,Object> properties = exp.getProperties();
            if (errorCode != null) {
                sb.append(
                        errorCode.getCode() + ":"+errorCode.getValue() + ":"+ 
                        errorCode + ":" + errorCode.getClass().getName()+"
    "
                        ); 
            }
            for (String key : properties.keySet()) {
                sb.append(key + "=[" + properties.get(key) + "]
    "); 
            }
            return sb.toString();
        }
    }
    
  • 相关阅读:
    浅谈 iOS 事件的传递和响应过程
    iOS 之渐变颜色
    系统enum的一些样式
    Storyboard操作的2个小技巧
    iOS 动画初步
    iOS之Runtime初应用
    Block使有注意点
    使用ios系统自带分享
    IOS原生地图与高德地图
    反向传值实例
  • 原文地址:https://www.cnblogs.com/bilaisheng/p/10211008.html
Copyright © 2011-2022 走看看