1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.whatsnew.exceptions;
17
18 import net.sf.whatsnew.lang.Messages;
19
20
21 /***
22 * <p>
23 * Application Level exception
24 * </p>
25 *
26 * @author <a href="mailto:dquintela@users.sourceforge.net">Diogo Quintela</a>
27 * @version $Id: AppException.java,v 1.1 2004/05/13 01:22:39 dquintela Exp $
28 */
29 public class AppException
30 extends Exception {
31 /***
32 * Creates a new AppException object.
33 */
34 public AppException() {
35 super();
36 }
37
38 /***
39 * Creates a new AppException object, with message identified with
40 * <code>key</code>
41 *
42 * @param key the detail message.
43 *
44 * @see net.sf.whatsnew.lang.Messages
45 */
46 public AppException(String key) {
47 this(key, false);
48 }
49
50 /***
51 * Creates a new AppException object.
52 *
53 * @param value The value for the key or the message
54 * @param useBundle true, <code>value</code> will be used as message
55 * identifier, false, <code>value</code> will be message associated
56 * with exception
57 *
58 * @see net.sf.whatsnew.lang.Messages
59 */
60 public AppException(
61 String value,
62 boolean useBundle) {
63 super(useBundle ? Messages.getString(value) : value);
64 }
65
66 /***
67 * Prints exception
68 *
69 * @param debug Debug on or off
70 */
71 public void print(boolean debug) {
72 if (debug) {
73 printStackTrace();
74 } else {
75 synchronized (System.err) {
76 System.err.print(this);
77 }
78 }
79 }
80 }
81