Pre Merge pull request !501 from EFT/dev-ExceptionUtil

This commit is contained in:
EFT 2024-06-14 15:13:15 +00:00 committed by Gitee
commit 7fabf6d534
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 6 additions and 9 deletions

View File

@ -11,6 +11,9 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
*/
public class ExceptionUtil
{
private ExceptionUtil() {}
/**
* 获取exception的详细错误信息
*/
@ -24,16 +27,10 @@ public class ExceptionUtil
public static String getRootErrorMessage(Exception e)
{
Throwable root = ExceptionUtils.getRootCause(e);
root = (root == null ? e : root);
if (root == null)
if (null == root)
{
return "";
return StringUtils.EMPTY;
}
String msg = root.getMessage();
if (msg == null)
{
return "null";
}
return StringUtils.defaultString(msg);
return StringUtils.defaultString(root.getMessage(), "null");
}
}