error.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ZORBA_ERROR_API_H
18 #define ZORBA_ERROR_API_H
19 
20 #include <zorba/internal/system_diagnostic.h>
21 #include <zorba/internal/qname.h>
22 
23 namespace zorba {
24 
25 class Diagnostic;
26 namespace serialization {
27  class Archiver;
28  void operator&( serialization::Archiver&, const Diagnostic*& );
29 }
30 
31 ///////////////////////////////////////////////////////////////////////////////
32 
33 typedef Diagnostic Error;
34 
35 /**
36  * An %XQueryErrorCode is a diagnostic for all XQuery-specific errors.
37  */
38 typedef internal::SystemDiagnostic<internal::XQueryErrQName> XQueryErrorCode;
39 
40 /**
41  * A %ZorbaErrorCode is a diagnostic for all Zorba-specific errors.
42  */
43 typedef internal::SystemDiagnostic<internal::ZorbaErrQName> ZorbaErrorCode;
44 
45 #ifdef ZORBA_WITH_JSON
46 /**
47  * An %JSONiqErrorCode is a diagnostic for all JSONiq-specific errors.
48  */
49 typedef internal::SystemDiagnostic<internal::JSONiqErrQName> JSONiqErrorCode;
50 #endif
51 
52 ///////////////////////////////////////////////////////////////////////////////
53 
54 /**
55  * A %UserError is-a Diagnostic for user-defined errors via \c fn:error().
56  */
57 class ZORBA_DLL_PUBLIC UserError : public Diagnostic {
58 public:
59  /**
60  * Copy-constructs a %UserError.
61  *
62  * @param from The %UserError to copy from.
63  */
64  UserError( UserError const &from );
65 
66  /**
67  * Destroys this %UserError.
68  */
69  ~UserError();
70 
71  /**
72  * Assigns this %UserError from another.
73  *
74  * @param from The %UserError to assign from.
75  * @return Returns \c *this.
76  */
77  UserError& operator=( UserError const &from );
78 
79  // inherited
80  diagnostic::QName const& qname() const;
81  diagnostic::category category() const;
82 
83 protected:
84  // inherited
85  Diagnostic const* clone() const;
86 
87 private:
88  typedef internal::VariableQName<std::string> QName;
89  QName qname_;
90 
91  /**
92  * Constructs a %UserError.
93  *
94  * @param ns The error's namespace URI.
95  * @param prefix The error's prefix.
96  * @param localname The error's local-name.
97  */
98  UserError( char const *ns, char const *prefix, char const *localname );
99 
100  friend class UserException;
101  friend UserError make_user_error( char const*, char const*, char const* );
102 
103  // for plan serialization
104  UserError( serialization::Archiver& );
105  friend void serialization::operator&( serialization::Archiver&,
106  const Diagnostic*& );
107 };
108 
109 ///////////////////////////////////////////////////////////////////////////////
110 
111 } // namespace zorba
112 #endif /* ZORBA_ERROR_API_H */
113 /*
114  * Local variables:
115  * mode: c++
116  * End:
117  */
118 /* vim:set et sw=2 ts=2: */
Diagnostic Error
Definition: error.h:33
internal::SystemDiagnostic< internal::ZorbaErrQName > ZorbaErrorCode
A ZorbaErrorCode is a diagnostic for all Zorba-specific errors.
Definition: error.h:43
internal::SystemDiagnostic< internal::XQueryErrQName > XQueryErrorCode
An XQueryErrorCode is a diagnostic for all XQuery-specific errors.
Definition: error.h:38
A UserError is-a Diagnostic for user-defined errors via fn:error().
Definition: error.h:57
void operator&(serialization::Archiver &, const Diagnostic *&)