Skip to main content

Table 4 Examples EH anti-patterns found

From: Studying the evolution of exception handling anti-patterns in a long-lived large-scale project

//Example of Destructive Wrapping 
try { 
if(con != null) con.close(); 
} catch (SQLException e) { 
throw new DataException(e.getMessage()); 
//Example of Catch Generic 
try { 
cal = CalendarHelper.getCalendar(getCurrentUser()); 
} catch (Exception e) { 
//Example of Throws Generic 
public Object method(HttpServletRequest req) 
throws Exception { 
GenericDataAccess dao = getGeneric(); 
Object obj = getCommandClass().newInstance(); 
return obj;