1 5 package org.exoplatform.faces.core.event; 6 7 import java.util.MissingResourceException ; 8 import java.util.ResourceBundle ; 9 15 abstract public class ExceptionHandler { 16 17 public ExceptionHandler() { 18 19 } 20 21 abstract public boolean canHandleError(Throwable error) ; 22 23 abstract public void handle(ExoActionEvent action, Throwable error) ; 24 25 protected String getStackTrace(Throwable t, int numberOfLine) { 26 StackTraceElement [] elements = t.getStackTrace() ; 27 if(numberOfLine > elements.length) numberOfLine = elements.length ; 28 StringBuffer b = new StringBuffer () ; 29 b.append(t.getMessage()).append("\n") ; 30 for(int i = 0; i < numberOfLine; i++) { 31 b.append(elements[i].toString()).append("\n") ; 32 } 33 return b.toString() ; 34 } 35 36 protected String getResource(ResourceBundle res , String key) { 37 try { 38 return res.getString(key) ; 39 } catch (MissingResourceException ex) { } 40 return null; 41 } 42 } | Popular Tags |