I am a C programmer and just learning some java recently because I am developing one android application. Currently I am in a situation. Following is the one.
I always do it like this :
public void MyMethod() throws Exception { //code here if(something is wrong) throw new Exception("Something wrong"); }
then when you call the function
try{ MyMethod(); }catch(Exception e){ System.out.println(e.getMessage()); }