1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jdiagnose;
17
18 import java.io.OutputStreamWriter;
19 import java.io.PrintStream;
20 import java.io.PrintWriter;
21
22
23 /***
24 * Useful for creating exceptions out of DiagnosticMessages
25 *
26 * @author jmccrindle
27 */
28 public class StoredException extends DiagnosticException {
29
30 private final String message;
31 private final String body;
32
33 /***
34 * @param message the exceptions message
35 * @param body the stacktrace
36 */
37 public StoredException(String message, String body) {
38 this.message = message;
39 this.body = body;
40 }
41
42 /***
43 * @see java.lang.Throwable#getMessage()
44 */
45 public String getMessage() {
46 return message;
47 }
48
49 /***
50 * @see java.lang.Throwable#getLocalizedMessage()
51 */
52 public String getLocalizedMessage() {
53 return message;
54 }
55
56 /***
57 * @see java.lang.Throwable#printStackTrace()
58 */
59 public void printStackTrace() {
60 printStackTrace(System.out);
61 }
62
63 /***
64 * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
65 */
66 public void printStackTrace(PrintStream out) {
67 printStackTrace(new PrintWriter(new OutputStreamWriter(out)));
68 }
69
70 /***
71 * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
72 */
73 public void printStackTrace(PrintWriter out) {
74 out.println(message);
75 out.println(body);
76 }
77 }