KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > groovy > control > messages > ExceptionMessage


1 package org.codehaus.groovy.control.messages;
2
3 import java.io.PrintWriter JavaDoc;
4
5 import org.codehaus.groovy.control.Janitor;
6 import org.codehaus.groovy.control.ProcessingUnit;
7
8
9
10 /**
11  * A class for error messages produced by the parser system.
12  *
13  * @author <a HREF="mailto:cpoirier@dreaming.org">Chris Poirier</a>
14  *
15  * @version $Id: ExceptionMessage.java,v 1.2 2004/07/10 03:31:41 bran Exp $
16  */

17
18 public class ExceptionMessage extends Message
19 {
20     private Exception JavaDoc cause = null; // The exception source of the message, if any
21

22
23     public ExceptionMessage( Exception JavaDoc cause )
24     {
25         this.cause = cause;
26     }
27     
28     
29    
30    /**
31     * Returns the underlying Exception.
32     */

33
34     public Exception JavaDoc getCause()
35     {
36         return this.cause;
37     }
38     
39
40
41    /**
42     * Writes out a nicely formatted summary of the exception.
43     */

44     
45     public void write( PrintWriter JavaDoc output, ProcessingUnit context, Janitor janitor )
46     {
47         String JavaDoc description = "General error during " + context.getPhaseDescription() + ": ";
48         
49         String JavaDoc message = cause.getMessage();
50         if( message != null )
51         {
52             output.println( description + message );
53         }
54         else
55         {
56             output.println( description + cause );
57         }
58         output.println("");
59     }
60     
61     
62 }
63
64
65
66
Popular Tags