001package org.dromara.warm.flow.core.utils; 002 003 004import java.io.PrintWriter; 005import java.io.StringWriter; 006 007/** 008 * 错误信息处理类。 009 * 010 * @author warm 011 */ 012public class ExceptionUtil { 013 /** 014 * 获取exception的详细错误信息。 015 */ 016 public static String getExceptionMessage(Throwable e) { 017 StringWriter sw = new StringWriter(); 018 e.printStackTrace(new PrintWriter(sw, true)); 019 return sw.toString(); 020 } 021 022 /** 023 * 处理消息是否显示中文 024 */ 025 public static String handleMsg(String msg, Exception e) { 026 if (StringUtils.isEmpty(msg)) { 027 return e.getMessage(); 028 } else { 029 return msg + ": " + e.getMessage(); 030 } 031 } 032}