Как распространить исключение в Java
Я программист на 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 () где-то еще в другом классе. Если кто-то может предоставить мне фрагмент кода, как распространить исключения на вызывающую функцию MyMethod (), чтобы я мог отобразить их в диалоговом окне в методе вызывающей стороны.
Извините, если я не так ясно и странно задаю этот вопрос.