001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.gwt;
029
030import com.google.gwt.user.client.rpc.IsSerializable;
031
032/**
033 * GWT RPC Exception. Wrapper for exceptions thrown while processing a RPC request.<p>
034 *
035 * As of the current state of exception serialization within GWT,
036 * details of the original throwable are kept to be available on the client.<p>
037 *
038 * @since 8.0.0
039 */
040public class CmsRpcException extends Exception implements IsSerializable {
041
042    /** Serialization uid. */
043    private static final long serialVersionUID = 7582056307629544840L;
044
045    /** The original cause message. */
046    private String m_originalCauseMessage;
047
048    /** The original class name. */
049    private String m_originalClassName;
050
051    /** The original message. */
052    private String m_originalMessage;
053
054    /** The original stack trace. */
055    private StackTraceElement[] m_originalStackTrace;
056
057    /**
058     * Default constructor.<p>
059     */
060    public CmsRpcException() {
061
062        // empty
063    }
064
065    /**
066     * Default constructor.<p>
067     *
068     * @param t the cause
069     */
070    public CmsRpcException(Throwable t) {
071
072        super(t);
073        setOriginalStackTrace(t.getStackTrace());
074        setOriginalMessage(t.getLocalizedMessage());
075        setOriginalClassName(t.getClass().getName());
076        if (t.getCause() != null) {
077            setOriginalCauseMessage(t.getCause().getLocalizedMessage());
078        }
079    }
080
081    /**
082     * Returns the cause message.<p>
083     *
084     * @return the cause message
085     */
086    public String getOriginalCauseMessage() {
087
088        return m_originalCauseMessage;
089    }
090
091    /**
092     * Returns the original class name.<p>
093     *
094     * @return the original class name
095     */
096    public String getOriginalClassName() {
097
098        return m_originalClassName;
099    }
100
101    /**
102     * Returns the original message.<p>
103     *
104     * @return the original message
105     */
106    public String getOriginalMessage() {
107
108        return m_originalMessage;
109    }
110
111    /**
112     * Returns the original stack trace.<p>
113     *
114     * @return the original stack trace
115     */
116    public StackTraceElement[] getOriginalStackTrace() {
117
118        return m_originalStackTrace;
119    }
120
121    /**
122     * Sets the original class name.<p>
123     *
124     * @param originalClassName the original class name to set
125     */
126    public void setOriginalClassName(String originalClassName) {
127
128        m_originalClassName = originalClassName;
129    }
130
131    /**
132     * Sets the original message.<p>
133     *
134     * @param originalMessage the original message to set
135     */
136    public void setOriginalMessage(String originalMessage) {
137
138        m_originalMessage = originalMessage;
139    }
140
141    /**
142     * Sets the original cause message.<p>
143     *
144     * @param originalCauseMessage  the original cause message
145     */
146    protected void setOriginalCauseMessage(String originalCauseMessage) {
147
148        m_originalCauseMessage = originalCauseMessage;
149    }
150
151    /**
152     * Sets the original stack trace.<p>
153     *
154     * @param trace the original stack trace
155     */
156    protected void setOriginalStackTrace(StackTraceElement[] trace) {
157
158        m_originalStackTrace = trace;
159    }
160}