> The XQuery Processor
00001 /* 00002 * Copyright 2006-2008 The FLWOR Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef ZORBA_EXCEPTION_API_H 00017 #define ZORBA_EXCEPTION_API_H 00018 00019 #include <zorba/error.h> 00020 #include <zorba/zorbastring.h> 00021 00022 namespace zorba { 00023 00024 /** \brief Base class of all exceptions thrown by %Zorba. 00025 */ 00026 class ZorbaException 00027 { 00028 public: 00029 /** \brief Destructor 00030 */ 00031 virtual ~ZorbaException() throw(); 00032 00033 /** \brief Get the ErrorCode of the error that is reported by this exception. 00034 */ 00035 virtual ZorbaError::ErrorCode 00036 getErrorCode() const; 00037 00038 /** \brief Get the descriptionof the error that is reported by this exception. 00039 */ 00040 virtual String 00041 getDescription() const; 00042 00043 /** \brief Get the name of the source file in which the error occured. 00044 * 00045 * Note that this information is mainly for debugging purposes. 00046 * 00047 * @return String the name of the file where the error occured. 00048 */ 00049 virtual String 00050 getFileName() const; 00051 00052 /** \brief Get the line number in the source file in which the error occured. 00053 * 00054 * Note that this information is mainly for debugging purposes. 00055 * 00056 * @return unsigned int the line number in the source file. 00057 */ 00058 virtual unsigned int 00059 getFileLineNumber() const; 00060 00061 00062 protected: 00063 friend class ZorbaImpl; 00064 /** \brief Proctected constructor - only the %Zorba engine can construct and throw 00065 * exceptions. 00066 */ 00067 ZorbaException(const ZorbaError::ErrorCode&, const String& aDescription, 00068 const String& aFileName, unsigned int aFileLineNumber); 00069 00070 ZorbaError::ErrorCode theErrorCode; 00071 String theDescription; 00072 String theFileName; 00073 unsigned int theFileLineNumber; 00074 }; 00075 00076 /** \brief QueryException is the base class for all errors that occur during query processing 00077 * and have a direct connection to the query, i.e. information about the location 00078 * where the error occured in the query is available. 00079 */ 00080 class QueryException : public ZorbaException 00081 { 00082 public: 00083 /** \brief Destructor 00084 */ 00085 virtual ~QueryException() throw(); 00086 00087 /** \brief Get the line number in the query where the error occured. 00088 * 00089 * @return unsigned int the line number in the query. 00090 */ 00091 virtual unsigned int 00092 getLineBegin() const; 00093 00094 /** \brief Get the column number in the query where the error occured. 00095 * 00096 * @return unsigned int the column number in the query. 00097 */ 00098 virtual unsigned int 00099 getColumnBegin() const; 00100 00101 protected: 00102 friend std::ostream& operator<<(std::ostream&, const QueryException&); 00103 friend class ZorbaImpl; 00104 00105 /** \brief Proctected constructor - only the %Zorba engine can construct and throw 00106 * exceptions. 00107 */ 00108 QueryException( 00109 const ZorbaError::ErrorCode&, 00110 const String& aDescription, 00111 const String& afilename, 00112 unsigned int afilelinenumber, 00113 unsigned int linebegin, 00114 unsigned int columnbegin); 00115 00116 protected: 00117 unsigned int theLineBegin; 00118 unsigned int theColumnBegin; 00119 }; 00120 00121 00122 /** \brief DynamicException represents a dynamic error as defined in the %XQuery 1.0 00123 * Specification (see http://www.w3.org/TR/xquery/#id-kinds-of-errors). 00124 */ 00125 class DynamicException : public QueryException 00126 { 00127 friend std::ostream& operator<<(std::ostream&, const DynamicException&); 00128 friend class ZorbaImpl; 00129 00130 public: 00131 /** \brief Destructor 00132 */ 00133 virtual ~DynamicException() throw(); 00134 00135 protected: 00136 /** \brief Proctected constructor - only the %Zorba engine can construct and throw 00137 * exceptions. 00138 */ 00139 DynamicException( 00140 const ZorbaError::ErrorCode&, 00141 const String&, 00142 const String& afilename, 00143 unsigned int afilelinenumber, 00144 unsigned int linebegin, 00145 unsigned int columnbegin); 00146 }; 00147 00148 00149 /** \brief StaticException represents a static error as defined in the %XQuery 1.0 00150 * Specification (see http://www.w3.org/TR/xquery/#id-kinds-of-errors). 00151 */ 00152 class StaticException : public QueryException 00153 { 00154 friend std::ostream& operator<<(std::ostream&, const StaticException&); 00155 friend class ZorbaImpl; 00156 00157 00158 public: 00159 /** \brief Destructor 00160 */ 00161 virtual ~StaticException() throw(); 00162 00163 protected: 00164 /** \brief Proctected constructor - only the %Zorba engine can construct and throw 00165 * exceptions. 00166 */ 00167 StaticException( 00168 const ZorbaError::ErrorCode&, 00169 const String&, 00170 const String& afilename, 00171 unsigned int afilelinenumber, 00172 unsigned int linebegin, 00173 unsigned int columnbegin); 00174 }; 00175 00176 00177 /** \brief TypeException represents a type error as defined in the %XQuery 1.0 00178 * Specification (see http://www.w3.org/TR/xquery/#id-kinds-of-errors). 00179 */ 00180 class TypeException : public QueryException 00181 { 00182 friend std::ostream& operator<<(std::ostream&, const TypeException&); 00183 friend class ZorbaImpl; 00184 00185 00186 public: 00187 /** \brief Destructor 00188 */ 00189 virtual ~TypeException() throw(); 00190 00191 protected: 00192 /** \brief Proctected constructor - only the %Zorba engine can construct and throw 00193 * exceptions. 00194 */ 00195 TypeException( 00196 const ZorbaError::ErrorCode&, 00197 const String&, 00198 const String& afilename, 00199 unsigned int afilelinenumber, 00200 unsigned int linebegin, 00201 unsigned int columnbegin); 00202 00203 }; 00204 00205 00206 /** \brief SerializationException represents a serialization error as defined in the 00207 * XSLT 2.0 and XQuery 1.0 Serialization Specification 00208 * (see http://www.w3.org/TR/2005/CR-xslt-xquery-serialization-20051103/) 00209 */ 00210 class SerializationException : public QueryException 00211 { 00212 friend std::ostream& operator<<(std::ostream&, const SerializationException&); 00213 friend class ZorbaImpl; 00214 00215 public: 00216 /** \brief Destructor 00217 */ 00218 virtual ~SerializationException() throw(); 00219 00220 protected: 00221 /** \brief Proctected constructor - only the %Zorba engine can construct and throw 00222 * exceptions. 00223 */ 00224 SerializationException( 00225 const ZorbaError::ErrorCode&, 00226 const String& aDescription, 00227 const String& afilename, 00228 unsigned int afilelinenumber, 00229 unsigned int linebegin, 00230 unsigned int columnbegin); 00231 00232 }; 00233 00234 /** \brief SystemException represents an error that occurs in the %Zorba system. 00235 */ 00236 class SystemException : public ZorbaException 00237 { 00238 friend std::ostream& operator<<(std::ostream&, const ZorbaException&); 00239 friend class ZorbaImpl; 00240 friend class Item; 00241 00242 public: 00243 /** \brief Destructor 00244 */ 00245 virtual ~SystemException() throw(); 00246 00247 protected: 00248 /** \brief Proctected constructor - only the %Zorba engine can construct and throw 00249 * exceptions. 00250 */ 00251 SystemException(const ZorbaError::ErrorCode&, const String& aDescription, 00252 const String& afilename, unsigned int afilelinenumber); 00253 00254 }; 00255 00256 00257 /** \brief Print information about the exception to the given output stream */ 00258 std::ostream& operator<< (std::ostream& os, const ZorbaException& aException); 00259 /** \brief Print information about the exception to the given output stream */ 00260 std::ostream& operator<< (std::ostream& os, const QueryException& aException); 00261 /** \brief Print information about the exception to the given output stream */ 00262 std::ostream& operator<< (std::ostream& os, const StaticException& aException); 00263 /** \brief Print information about the exception to the given output stream */ 00264 std::ostream& operator<< (std::ostream& os, const DynamicException& aException); 00265 /** \brief Print information about the exception to the given output stream */ 00266 std::ostream& operator<< (std::ostream& os, const TypeException& aException); 00267 /** \brief Print information about the exception to the given output stream */ 00268 std::ostream& operator<< (std::ostream& os, const SerializationException& aException); 00269 /** \brief Print information about the exception to the given output stream */ 00270 std::ostream& operator<< (std::ostream& os, const SystemException& aException); 00271 00272 } /* namespace zorba */ 00273 #endif