01: package org.codehaus.groovy.control.messages;
02:
03: import java.io.PrintWriter;
04:
05: import org.codehaus.groovy.control.Janitor;
06: import org.codehaus.groovy.control.ProcessingUnit;
07:
08: /**
09: * A class for error messages produced by the parser system.
10: *
11: * @author <a href="mailto:cpoirier@dreaming.org">Chris Poirier</a>
12: *
13: * @version $Id: ExceptionMessage.java 4098 2006-10-10 16:09:48Z blackdrag $
14: */
15:
16: public class ExceptionMessage extends Message {
17: protected boolean verbose = true;
18:
19: private Exception cause = null; // The exception source of the message, if any
20: ProcessingUnit owner = null;
21:
22: public ExceptionMessage(Exception cause, boolean v,
23: ProcessingUnit owner) {
24: this .verbose = v;
25: this .cause = cause;
26: this .owner = owner;
27: }
28:
29: /**
30: * Returns the underlying Exception.
31: */
32:
33: public Exception getCause() {
34: return this .cause;
35: }
36:
37: /**
38: * Writes out a nicely formatted summary of the exception.
39: */
40:
41: public void write(PrintWriter output, Janitor janitor) {
42: String description = "General error during "
43: + owner.getPhaseDescription() + ": ";
44:
45: String message = cause.getMessage();
46: if (message != null) {
47: output.println(description + message);
48: } else {
49: output.println(description + cause);
50: }
51: output.println();
52:
53: //if (verbose) {
54: cause.printStackTrace(output);
55: //}
56: }
57:
58: }
|