001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/widgets/CmsWidgetException.java,v $
003: * Date : $Date: 2008-02-27 12:05:44 $
004: * Version: $Revision: 1.9 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.widgets;
033:
034: import org.opencms.i18n.CmsMessageContainer;
035: import org.opencms.main.CmsException;
036: import org.opencms.workplace.CmsWidgetDialogParameter;
037:
038: /**
039: * Describes errors that occur in the context of the OpenCms widgets.<p>
040: *
041: * @author Alexander Kandzior
042: *
043: * @version $Revision: 1.9 $
044: *
045: * @since 6.0.0
046: */
047: public class CmsWidgetException extends CmsException {
048:
049: /** Serial version UID required for safe serialization. */
050: private static final long serialVersionUID = -7003923645953106868L;
051:
052: /** The widget that caused the error. */
053: private transient CmsWidgetDialogParameter m_widget;
054:
055: /**
056: * Creates a new localized Exception.<p>
057: *
058: * @param container the localized message container to use
059: */
060: public CmsWidgetException(CmsMessageContainer container) {
061:
062: this (container, (CmsWidgetDialogParameter) null);
063: }
064:
065: /**
066: * Creates a new localized Exception.<p>
067: *
068: * @param container the localized message container to use
069: * @param widget the widget that caused the error
070: */
071: public CmsWidgetException(CmsMessageContainer container,
072: CmsWidgetDialogParameter widget) {
073:
074: super (container);
075: m_widget = widget;
076: }
077:
078: /**
079: * Creates a new localized Exception that also containes a root cause.<p>
080: *
081: * @param container the localized message container to use
082: * @param cause the Exception root cause
083: */
084: public CmsWidgetException(CmsMessageContainer container,
085: Throwable cause) {
086:
087: this (container, cause, null);
088: }
089:
090: /**
091: * Creates a new localized Exception that also containes a root cause.<p>
092: *
093: * @param container the localized message container to use
094: * @param cause the Exception root cause
095: * @param widget the widget that caused the error
096: */
097: public CmsWidgetException(CmsMessageContainer container,
098: Throwable cause, CmsWidgetDialogParameter widget) {
099:
100: super (container, cause);
101: m_widget = widget;
102: }
103:
104: /**
105: * @see org.opencms.main.CmsException#createException(org.opencms.i18n.CmsMessageContainer, java.lang.Throwable)
106: */
107: public CmsException createException(CmsMessageContainer container,
108: Throwable cause) {
109:
110: if (cause instanceof CmsWidgetException) {
111: return new CmsWidgetException(container, cause,
112: ((CmsWidgetException) cause).getWidget());
113: }
114: return new CmsWidgetException(container, cause);
115: }
116:
117: /**
118: * Returns the widget that caused the error.<p>
119: *
120: * If the widget has not been set, this will return <code>null</code>.<p>
121: *
122: * @return the widget that caused the error
123: */
124: public CmsWidgetDialogParameter getWidget() {
125:
126: return m_widget;
127: }
128: }
|