FDO API Reference | Feature Data Objects |
00001 #ifndef _FDO_EXCEPTION_H_ 00002 #define _FDO_EXCEPTION_H_ 00003 // 00004 00005 // 00006 // Copyright (C) 2004-2006 Autodesk, Inc. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of version 2.1 of the GNU Lesser 00010 // General Public License as published by the Free Software Foundation. 00011 // 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 // Lesser General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public 00018 // License along with this library; if not, write to the Free Software 00019 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 // 00021 00022 #ifdef _WIN32 00023 #pragma once 00024 #endif 00025 00026 #include <FdoMessage.h> 00027 #include <stdarg.h> 00028 00029 #ifdef _DEBUG 00030 #define FDO_NLSID(x) x, #x, __FILE__, __LINE__ 00031 #else 00032 #define FDO_NLSID(x) x, #x 00033 #endif 00034 00035 template <class T> class FdoPtr; 00036 00037 /// \brief 00038 /// FdoException is a root class for the exception type thrown from classes. It derives from a language 00039 /// level exception class that is environment specific. 00040 class FdoException : public FdoIDisposable 00041 { 00042 protected: 00043 /// Constructs a default instance of a FdoException. 00044 FDO_API_COMMON FdoException(); 00045 00046 /// Constructs an instance of a FdoException using the specified arguments. 00047 FDO_API_COMMON FdoException(FdoString* message); 00048 00049 /// Constructs an instance of a FdoException using the specified arguments. 00050 FDO_API_COMMON FdoException(FdoString* message, FdoException* cause); 00051 00052 /// Default destructor for FdoException class. 00053 FDO_API_COMMON virtual ~FdoException(); 00054 00055 /// \cond DOXYGEN-IGNORE 00056 virtual void Dispose(); 00057 /// \endcond 00058 00059 public: 00060 /// \brief 00061 /// Returns a default instance of a FdoException. 00062 /// 00063 /// \return 00064 /// Returns the FdoException object 00065 /// 00066 FDO_API_COMMON static FdoException* Create(); 00067 00068 /// \brief 00069 /// Returns an instance of a FdoException using the specified arguments. 00070 /// 00071 /// \param message 00072 /// Input the error message 00073 /// 00074 /// \return 00075 /// Returns the FdoException object 00076 /// 00077 FDO_API_COMMON static FdoException* Create(FdoString* message); 00078 00079 /// \brief 00080 /// Returns an instance of a FdoException using the specified arguments. 00081 /// 00082 /// \param message 00083 /// Input the error message 00084 /// \param cause 00085 /// Input the cause of the error 00086 /// 00087 /// \return 00088 /// Returns the FdoException object 00089 /// 00090 FDO_API_COMMON static FdoException* Create(FdoString* message, FdoException* cause); 00091 00092 /// \brief 00093 /// Gets the message associated with this exception. If no message is 00094 /// associated with this exception but it has a cause, then this method 00095 /// returns the message specified for the cause exception. If no message and 00096 /// no cause are associated with this exception then a null reference is 00097 /// returned. 00098 /// 00099 /// \return 00100 /// Returns the error message 00101 /// 00102 FDO_API_COMMON virtual FdoString* GetExceptionMessage(); 00103 00104 /// \brief 00105 /// Gets a reference to the exception that caused this exception. 00106 /// 00107 /// \return 00108 /// Returns the cause of the error 00109 /// 00110 FDO_API_COMMON virtual FdoException* GetCause(); 00111 00112 /// \brief 00113 /// Gets a reference to the exception that is the root cause of this 00114 /// exception. 00115 /// 00116 /// \return 00117 /// Returns the root cause for the error 00118 /// 00119 FDO_API_COMMON virtual FdoException* GetRootCause(); 00120 00121 /// \brief 00122 /// Sets the cause exception 00123 /// 00124 /// \param cause 00125 /// Input the cause of the error 00126 /// 00127 /// \return 00128 /// Returns nothing 00129 /// 00130 FDO_API_COMMON virtual void SetCause( FdoException* cause ); 00131 00132 /// \brief 00133 /// Gets the message associated with this exception. If no message is 00134 /// associated with this exception but it has a cause, then this method 00135 /// returns the message specified for the cause exception. If no message and 00136 /// no cause are associated with this exception then a null reference is 00137 /// returned. 00138 /// 00139 /// \return 00140 /// Returns the error message 00141 /// 00142 FDO_API_COMMON virtual FdoString* ToString(); 00143 00144 /// \brief 00145 /// Gets the exception message. For internal use by template classes in getting a localized message. 00146 /// 00147 /// \remarks 00148 /// In addition to the listed parameters, a flexible number of additional variables, as required, 00149 /// can be used as input to format the exception message. 00150 /// 00151 /// \param msgNum 00152 /// Input the error message number 00153 /// \param defMsg 00154 /// Input a text error message to use if the message number is not found 00155 /// \param file 00156 /// Input file name where exception occurred 00157 /// \param line 00158 /// Input the line number where exception occurred 00159 /// 00160 /// \return 00161 /// Returns the localized message text 00162 /// 00163 FDO_API_COMMON static FdoString* NLSGetMessage(FdoInt32 msgNum, char* defMsg, char* file, int line, ...); 00164 00165 /// \brief 00166 /// Gets the exception message. For internal use by FdoException class in getting a localized message. 00167 /// 00168 /// \param msgNum 00169 /// Input the error message number 00170 /// \param defMsg 00171 /// Input a text error message to use if the message number is not found 00172 /// \param file 00173 /// Input file name where exception occurred 00174 /// \param line 00175 /// Input the line number where exception occurred 00176 /// \param catalog 00177 /// Input the NLS message catalog name. 00178 /// \param arguments 00179 /// Input the variable argument parameters from previous call. 00180 /// 00181 /// \return 00182 /// Returns the localized message text 00183 /// 00184 FDO_API_COMMON static FdoString* NLSGetMessage(FdoInt32 msgNum, char* defMsg, char* file, int line, char* catalog, va_list arguments); 00185 00186 /// \brief 00187 /// Gets the exception message. For internal use by template classes in getting a localized message. 00188 /// 00189 /// \remarks 00190 /// In addition to the listed parameters, a flexible number of additional variables, as required, 00191 /// can be used as input to format the exception message. 00192 /// 00193 /// \param msgNum 00194 /// Input the error message number 00195 /// \param defMsg 00196 /// Input a text error message to use if the message number is not found 00197 /// 00198 /// \return 00199 /// Returns the localized message text 00200 /// 00201 FDO_API_COMMON static FdoString* NLSGetMessage(FdoInt32 msgNum, char* defMsg, ...); 00202 00203 /// \brief 00204 /// Gets the exception message. For internal use by FdoException class in getting a localized message. 00205 /// 00206 /// \param msgNum 00207 /// Input the error message number 00208 /// \param defMsg 00209 /// Input a text error message to use if the message number is not found 00210 /// \param catalog 00211 /// Input the NLS message catalog name. 00212 /// \param arguments 00213 /// Input the variable argument parameters from previous call. 00214 /// 00215 /// \return 00216 /// Returns the localized message text 00217 /// 00218 FDO_API_COMMON static FdoString* NLSGetMessage(FdoInt32 msgNum, char* defMsg, char* catalog, va_list arguments); 00219 00220 protected: 00221 /// \cond DOXYGEN-IGNORE 00222 wchar_t* m_message; 00223 FdoException* m_cause; 00224 00225 00226 /// \endcond 00227 00228 }; 00229 /// FdoExceptionP is a FdoPtr on FdoException, provided for convenience. 00230 typedef FdoPtr<FdoException> FdoExceptionP; 00231 00232 #endif 00233 00234
Comments or suggestions? Send us feedback. |