Julho 06
Prof(s). Eduardo Bezerra & Ismael H. F. Santos                                                2
npublic void dataAccessCode(){
n  try{ ..some code that throws SQLException
n  } catch(SQLException ex){ ex.printStacktrace(); }
n}
n
nThis catch block just suppresses the exception and does nothing. The justification is that there is nothing my client could do about an SQLException. How about dealing with it in the following manner?
n
npublic void dataAccessCode(){
n  try{ ..some code that throws SQLException
n  } catch(SQLException ex){
n    throw new RuntimeException(ex);
n  }
n}
Best Practices for Designing API (cont.)