zoukankan      html  css  js  c++  java
  • 异常工具 获取异常信息 log.setExceptionDetail(ThrowableUtil.getStackTrace(e));

    /*
     *  Copyright 2019-2020 Zheng Jie
     *
     *  Licensed under the Apache License, Version 2.0 (the "License");
     *  you may not use this file except in compliance with the License.
     *  You may obtain a copy of the License at
     *
     *  http://www.apache.org/licenses/LICENSE-2.0
     *
     *  Unless required by applicable law or agreed to in writing, software
     *  distributed under the License is distributed on an "AS IS" BASIS,
     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     *  See the License for the specific language governing permissions and
     *  limitations under the License.
     */
    package me.zhengjie.utils;
    
    import java.io.PrintWriter;
    import java.io.StringWriter;
    
    /**
     * 异常工具 2019-01-06
     * @author Zheng Jie
     */
    public class ThrowableUtil {
    
        /**
         * 获取堆栈信息
         */
        public static String getStackTrace(Throwable throwable){
            StringWriter sw = new StringWriter();
            try (PrintWriter pw = new PrintWriter(sw)) {
                throwable.printStackTrace(pw);
                return sw.toString();
            }
        }
    }
  • 相关阅读:
    [HNOI2006]超级英雄
    [CTSC1999]家园
    火星探险问题
    [HNOI2008]GT考试
    [USACO14DEC]后卫马克Guard Mark
    [NOI2018]归程
    [USACO15DEC]最大流Max Flow
    [NOIPlus]斗地主
    [LUOGU] P3128 [USACO15DEC]最大流Max Flow
    [BZOJ] 1878: [SDOI2009]HH的项链
  • 原文地址:https://www.cnblogs.com/cuijinlong/p/15010997.html
Copyright © 2011-2022 走看看