你可以试试:
try {
. . .
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
编辑(受到Sujan Sivagurunathan 的回答的启发:如果异常可能是次要异常(由于另一个异常而引发的异常),您可以执行此更详细的版本:
try {
. . .
} catch (Exception e) {
e.printStackTrace();
for (Throwable t = e.getCause(); t != null; t = t.getCause()) {
System.err.println("Caused by:")
t.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3876 次 |
| 最近记录: |