KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > event > ExceptionHandler


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.faces.core.event;
6
7 import java.util.MissingResourceException JavaDoc;
8 import java.util.ResourceBundle JavaDoc;
9 /**
10  * Jun 3, 2004
11  * @author: Tuan Nguyen
12  * @email: tuan08@users.sourceforge.net
13  * @version: $ID$
14  **/

15 abstract public class ExceptionHandler {
16  
17   public ExceptionHandler() {
18     
19   }
20   
21   abstract public boolean canHandleError(Throwable JavaDoc error) ;
22   
23   abstract public void handle(ExoActionEvent action, Throwable JavaDoc error) ;
24   
25   protected String JavaDoc getStackTrace(Throwable JavaDoc t, int numberOfLine) {
26     StackTraceElement JavaDoc[] elements = t.getStackTrace() ;
27     if(numberOfLine > elements.length) numberOfLine = elements.length ;
28     StringBuffer JavaDoc b = new StringBuffer JavaDoc() ;
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 JavaDoc getResource(ResourceBundle JavaDoc res , String JavaDoc key) {
37     try {
38       return res.getString(key) ;
39     } catch (MissingResourceException JavaDoc ex) { }
40     return null;
41   }
42 }
Popular Tags