KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jzonic > jlo > error > ConsoleErrorReporter


1 package org.jzonic.jlo.error;
2 /**
3  * The ErrorHandler is used when an exception occurs in the framework. The
4  * exception must not be thrown back to the application that uses jLo.
5  * Therefore we use our own ErrorHandler that sends the Exception together with
6  * a message to System.out.
7  *
8  *@author Andreas Mecky
9  *@author Terry Dye
10  *@created 9. März 2002
11  *@version 1.0
12  */

13 public class ConsoleErrorReporter implements ErrorReporter {
14     /**
15      * Constructor for the ErrorHandler object
16      */

17     public ConsoleErrorReporter() { }
18
19
20     /**
21      * This method writes a message
22      *
23      *@param message the message that will be written to System.out
24      */

25     public void reportError(String JavaDoc message) {
26         reportError(message,null);
27     }
28
29
30     /**
31      * This method writes a message together with the StackTrace from the
32      * exception
33      *
34      *@param message the message that will be written
35      *@param thrown the excption
36      */

37     public void reportError(String JavaDoc message, Throwable JavaDoc thrown) {
38         System.out.println(message);
39         if ( thrown != null ) {
40             thrown.printStackTrace();
41         }
42     }
43
44
45     /**
46      * This method writes the StackTrace from the exception
47      *
48      *@param thrown the excption
49      */

50     public void reportError(Throwable JavaDoc thrown) {
51         thrown.printStackTrace();
52     }
53 }
54
Popular Tags