我有以下代码,我喜欢使用 finally 来获取异常消息,因为使用 catch 我可以很容易地通过它的 arg 获取。但是我知道我无法使用 finally 获取异常消息。
try {
MyClass obj=new MyClass();
obj.strProName = jobj1.getString("productname");
obj.strPrice = jobj1.getString("price");
obj.strCurrency = jobj1.getString("currency");
obj.strSalePrice = jobj1.getString("saleprice");
obj.strStoreName = jobj1.getString("storename");
//arrayList.add(obj);
throw new Exception("Exception Reason!");
}
finally{
//want to get that exception message here without using catch or can see how finally catching here the exception
}