我在代码中有一个try-catch
语句块,在我的catch块中,我调用e.getMessage()
打印异常的详细信息。但是,e.getMessage()
总是返回null值。有趣的是,当我调用e.printStackTrace()
时,我却没有问题地打印了堆栈跟踪。
以下是我的代码:
try
{
console = new BufferedReader(new InputStreamReader(httpsURLConnection.getInputStream()));
}catch(Exception e)
{
Log.d("Error", "Error Message: " + e.getMessage()); //e.getMessage is returning a null value
e.printStackTrace(); //this works. is displaying a SocketTimeOutException
}
我的问题可能是什么原因造成的?我该如何解决?