01: /* CommonException.java
02:
03: {{IS_NOTE
04:
05: Purpose: The most fundamental non-runtime exception
06: Description:
07: History:
08: 2001/6/1, Tom M. Yeh: Created.
09:
10: }}IS_NOTE
11:
12: Copyright (C) 2001 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.lang;
20:
21: import org.zkoss.mesg.Messageable;
22:
23: /**
24: * The most fundamental non-runtime exception of Potix classes.
25: * All exceptions specific to Potix classes must derive from
26: * SystemException or CommonException.
27: *
28: * <p>SystemException indicates programming bugs, while
29: * CommonException indicates exceptinal cases.
30: *
31: * @author tomyeh
32: * @see SystemException
33: */
34: public class CommonException extends Exception implements Messageable {
35: protected int _code = NULL_CODE;
36:
37: /**
38: * Constructs an CommonException by specifying message directly.
39: */
40: public CommonException(String msg, Throwable cause) {
41: super (msg, cause);
42: }
43:
44: public CommonException(String msg) {
45: super (msg);
46: }
47:
48: public CommonException(Throwable cause) {
49: super (cause);
50: }
51:
52: public CommonException() {
53: }
54:
55: /**
56: * Constructs an CommonException by use of an error code.
57: * The error code must be defined in
58: * one of properties files, e.g., msgsys.properties.
59: *
60: * @param code the error code
61: * @param fmtArgs the format arguments
62: * @param cause the chained throwable object
63: */
64: public CommonException(int code, Object[] fmtArgs, Throwable cause) {
65: super (Exceptions.getMessage(code, fmtArgs), cause);
66: _code = code;
67: }
68:
69: public CommonException(int code, Object fmtArg, Throwable cause) {
70: super (Exceptions.getMessage(code, fmtArg), cause);
71: _code = code;
72: }
73:
74: public CommonException(int code, Object[] fmtArgs) {
75: super (Exceptions.getMessage(code, fmtArgs));
76: _code = code;
77: }
78:
79: public CommonException(int code, Object fmtArg) {
80: super (Exceptions.getMessage(code, fmtArg));
81: _code = code;
82: }
83:
84: public CommonException(int code, Throwable cause) {
85: super (Exceptions.getMessage(code), cause);
86: _code = code;
87: }
88:
89: public CommonException(int code) {
90: super (Exceptions.getMessage(code));
91: _code = code;
92: }
93:
94: //-- Messageable --//
95: public final int getCode() {
96: return _code;
97: }
98: }
|