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.ugc.shared; 029 030import org.opencms.gwt.CmsRpcException; 031import org.opencms.ugc.shared.CmsUgcConstants.ErrorCode; 032 033/** 034 * Exception class for use in the org.opencms.editors.usergenerated module.<p> 035 * 036 */ 037public class CmsUgcException extends CmsRpcException { 038 039 /** Serial version id. */ 040 private static final long serialVersionUID = -8081364940852864867L; 041 042 /** Contains the error type. */ 043 private CmsUgcConstants.ErrorCode m_errorCode; 044 045 /** The human-readable error message. */ 046 private String m_message; 047 048 /** 049 * Creates a new instance.<p> 050 * 051 * @param errorCode the error type 052 * @param message the error message 053 */ 054 public CmsUgcException(CmsUgcConstants.ErrorCode errorCode, String message) { 055 056 setErrorCode(errorCode); 057 m_message = message; 058 } 059 060 /** 061 * Creates a new instance.<p> 062 * 063 * @param t the wrapped exception 064 */ 065 public CmsUgcException(Throwable t) { 066 067 super(t); 068 setErrorCode(ErrorCode.errMisc); 069 m_message = t.getLocalizedMessage(); 070 } 071 072 /** 073 * Creates a new instance.<p> 074 * 075 * @param t the original exception 076 * @param errorCode the error type 077 * @param message the error message 078 */ 079 public CmsUgcException(Throwable t, CmsUgcConstants.ErrorCode errorCode, String message) { 080 081 super(t); 082 setErrorCode(errorCode); 083 m_message = message; 084 } 085 086 /** 087 * Default constructor for serialization.<p> 088 */ 089 protected CmsUgcException() { 090 091 // do nothing 092 } 093 094 /** 095 * Returns the errorCode.<p> 096 * 097 * @return the errorCode 098 */ 099 public CmsUgcConstants.ErrorCode getErrorCode() { 100 101 return m_errorCode; 102 } 103 104 /** 105 * Gets the human-readable message.<p> 106 * 107 * @return the human-readable message 108 */ 109 public String getUserMessage() { 110 111 return m_message; 112 } 113 114 /** 115 * Sets the errorCode.<p> 116 * 117 * @param errorCode the errorCode to set 118 */ 119 public void setErrorCode(CmsUgcConstants.ErrorCode errorCode) { 120 121 m_errorCode = errorCode; 122 } 123 124}