【发布时间】:2012-03-18 22:40:09
【问题描述】:
我是一名 C 程序员,最近刚刚学习了一些 Java,因为我正在开发一个 Android 应用程序。目前我处于一种情况。以下是一个。
public Class ClassA{
public ClassA();
public void MyMethod(){
try{
//Some code here which can throw exceptions
}
catch(ExceptionType1 Excp1){
//Here I want to show one alert Dialog box for the exception occured for the user.
//but I am not able to show dialog in this context. So I want to propagate it
//to the caller of this method.
}
catch(ExceptionType2 Excp2){
//Here I want to show one alert Dialog box for the exception occured for the user.
//but I am not able to show dialog in this context. So I want to propagate it
//to the caller of this method.
}
}
}
现在我想在另一个类的其他地方调用 MyMethod() 方法。如果有人可以提供一些代码 sn-p 如何将异常传播给 MyMethod() 的调用者,以便我可以在调用者方法的对话框中显示它们。
对不起,如果我问这个问题的方式不是那么清楚和奇怪。
【问题讨论】:
标签: java exception propagation