forked from yangzongzhuan/RuoYi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fc4251
commit e34b4ea
Showing
24 changed files
with
424 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.ruoyi.common.utils; | ||
|
||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import org.apache.commons.lang3.exception.ExceptionUtils; | ||
|
||
/** | ||
* 错误信息处理类。 | ||
* | ||
* @author ruoyi | ||
*/ | ||
public class ExceptionUtil | ||
{ | ||
|
||
/** | ||
* 获取exception的详细错误信息。 | ||
*/ | ||
public static String getExceptionMessage(Throwable e) | ||
{ | ||
StringWriter sw = new StringWriter(); | ||
e.printStackTrace(new PrintWriter(sw, true)); | ||
String str = sw.toString(); | ||
return str; | ||
} | ||
|
||
public static String getRootErrorMseeage(Exception e) | ||
{ | ||
Throwable root = ExceptionUtils.getRootCause(e); | ||
root = (root == null ? e : root); | ||
if (root == null) | ||
{ | ||
return ""; | ||
} | ||
String msg = root.getMessage(); | ||
if (msg == null) | ||
{ | ||
return "null"; | ||
} | ||
return StringUtils.defaultString(msg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.