001: /* UiException.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Fri Jan 20 15:47:23 2006, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.zk.ui;
020:
021: import org.zkoss.lang.SystemException;
022: import org.zkoss.lang.Exceptions;
023: import org.zkoss.lang.Expectable;
024:
025: /**
026: * Represents an UI-relevant runtime exception.
027: *
028: * @author tomyeh
029: */
030: public class UiException extends SystemException {
031: /** Utilities.
032: *
033: * <p>The reason to use a class to hold static utilities is we can
034: * override the method's return type later.
035: */
036: public static class Aide {
037: /** Converts an exception to UiException or OperationException
038: * depending on whether t implements Expetable.
039: * @see Exceptions#wrap
040: */
041: public static UiException wrap(Throwable t) {
042: t = Exceptions.unwrap(t);
043: if (t instanceof Expectable)
044: return (OperationException) Exceptions.wrap(t,
045: OperationException.class);
046: return (UiException) Exceptions.wrap(t, UiException.class);
047: }
048:
049: /** Converts an exception to UiException or OperationException
050: * depending on whether t implements Expetable.
051: * @see Exceptions#wrap
052: */
053: public static UiException wrap(Throwable t, String msg) {
054: t = Exceptions.unwrap(t);
055: if (t instanceof Expectable)
056: return (OperationException) Exceptions.wrap(t,
057: OperationException.class, msg);
058: return (UiException) Exceptions.wrap(t, UiException.class,
059: msg);
060: }
061:
062: /** Converts an exception to UiException or OperationException
063: * depending on whether t implements Expetable.
064: * @see Exceptions#wrap
065: */
066: public static UiException wrap(Throwable t, int code,
067: Object[] fmtArgs) {
068: t = Exceptions.unwrap(t);
069: if (t instanceof Expectable)
070: return (OperationException) Exceptions.wrap(t,
071: OperationException.class, code, fmtArgs);
072: return (UiException) Exceptions.wrap(t, UiException.class,
073: code, fmtArgs);
074: }
075:
076: /** Converts an exception to UiException or OperationException
077: * depending on whether t implements Expetable.
078: * @see Exceptions#wrap
079: */
080: public static UiException wrap(Throwable t, int code,
081: Object fmtArg) {
082: t = Exceptions.unwrap(t);
083: if (t instanceof Expectable)
084: return (OperationException) Exceptions.wrap(t,
085: OperationException.class, code, fmtArg);
086: return (UiException) Exceptions.wrap(t, UiException.class,
087: code, fmtArg);
088: }
089:
090: /** Converts an exception to UiException or OperationException
091: * depending on whether t implements Expetable.
092: * @see Exceptions#wrap
093: */
094: public static UiException wrap(Throwable t, int code) {
095: t = Exceptions.unwrap(t);
096: if (t instanceof Expectable)
097: return (OperationException) Exceptions.wrap(t,
098: OperationException.class, code);
099: return (UiException) Exceptions.wrap(t, UiException.class,
100: code);
101: }
102: }
103:
104: public UiException(String msg, Throwable cause) {
105: super (msg, cause);
106: }
107:
108: public UiException(String s) {
109: super (s);
110: }
111:
112: public UiException(Throwable cause) {
113: super (cause);
114: }
115:
116: public UiException() {
117: }
118:
119: public UiException(int code, Object[] fmtArgs, Throwable cause) {
120: super (code, fmtArgs, cause);
121: }
122:
123: public UiException(int code, Object fmtArg, Throwable cause) {
124: super (code, fmtArg, cause);
125: }
126:
127: public UiException(int code, Object[] fmtArgs) {
128: super (code, fmtArgs);
129: }
130:
131: public UiException(int code, Object fmtArg) {
132: super (code, fmtArg);
133: }
134:
135: public UiException(int code, Throwable cause) {
136: super (code, cause);
137: }
138:
139: public UiException(int code) {
140: super(code);
141: }
142: }
|