1 | /* Copyright © 2005-2007 Roger Leigh <rleigh@debian.org> |
---|
2 | * |
---|
3 | * schroot is free software: you can redistribute it and/or modify it |
---|
4 | * under the terms of the GNU General Public License as published by |
---|
5 | * the Free Software Foundation, either version 3 of the License, or |
---|
6 | * (at your option) any later version. |
---|
7 | * |
---|
8 | * schroot is distributed in the hope that it will be useful, but |
---|
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
11 | * General Public License for more details. |
---|
12 | * |
---|
13 | * You should have received a copy of the GNU General Public License |
---|
14 | * along with this program. If not, see |
---|
15 | * <http://www.gnu.org/licenses/>. |
---|
16 | * |
---|
17 | *********************************************************************/ |
---|
18 | |
---|
19 | #ifndef SBUILD_PARSE_ERROR_H |
---|
20 | #define SBUILD_PARSE_ERROR_H |
---|
21 | |
---|
22 | #include <sbuild/sbuild-custom-error.h> |
---|
23 | #include <sbuild/sbuild-null.h> |
---|
24 | |
---|
25 | #include <map> |
---|
26 | #include <string> |
---|
27 | |
---|
28 | namespace sbuild |
---|
29 | { |
---|
30 | |
---|
31 | /** |
---|
32 | * Parse error. |
---|
33 | */ |
---|
34 | template<typename T> |
---|
35 | class parse_error : public error<T> |
---|
36 | { |
---|
37 | public: |
---|
38 | typedef typename error<T>::error_type error_type; |
---|
39 | |
---|
40 | /** |
---|
41 | * The constructor. |
---|
42 | * |
---|
43 | * @param context the context of the error. |
---|
44 | * @param error the error code. |
---|
45 | */ |
---|
46 | template<typename C> |
---|
47 | parse_error (C const& context, |
---|
48 | error_type error): |
---|
49 | sbuild::error<T>(format_error(context, null(), null(), error, null(), null(), null()), |
---|
50 | format_reason(context, null(), null(), error, null(), null(), null())) |
---|
51 | { |
---|
52 | } |
---|
53 | |
---|
54 | /** |
---|
55 | * The constructor. |
---|
56 | * |
---|
57 | * @param error the error code. |
---|
58 | * @param detail the details of the error. |
---|
59 | */ |
---|
60 | template<typename D> |
---|
61 | parse_error (error_type error, |
---|
62 | D const& detail): |
---|
63 | sbuild::error<T>(format_error(null(), null(), null(), error, detail, null(), null()), |
---|
64 | format_reason(null(), null(), null(), error, detail, null(), null())) |
---|
65 | { |
---|
66 | } |
---|
67 | |
---|
68 | /** |
---|
69 | * The constructor. |
---|
70 | * |
---|
71 | * @param line the line the error occurred on. |
---|
72 | * @param error the error code. |
---|
73 | * @param detail the details of the error. |
---|
74 | */ |
---|
75 | template<typename D> |
---|
76 | parse_error (size_t line, |
---|
77 | error_type error, |
---|
78 | D const& detail): |
---|
79 | sbuild::error<T>(format_error(line, null(), null(), error, detail, null(), null()), |
---|
80 | format_reason(line, null(), null(), error, detail, null(), null())) |
---|
81 | { |
---|
82 | } |
---|
83 | |
---|
84 | /** |
---|
85 | * The constructor. |
---|
86 | * |
---|
87 | * @param line the line the error occurred on. |
---|
88 | * @param group the group the error occurred within. |
---|
89 | * @param error the error code. |
---|
90 | * @param detail the details of the error. |
---|
91 | */ |
---|
92 | template<typename D> |
---|
93 | parse_error (size_t line, |
---|
94 | std::string const& group, |
---|
95 | error_type error, |
---|
96 | D const& detail): |
---|
97 | sbuild::error<T>(format_error(line, group, null(), error, detail, null(), null()), |
---|
98 | format_reason(line, group, null(), error, detail, null(), null())) |
---|
99 | { |
---|
100 | } |
---|
101 | |
---|
102 | /** |
---|
103 | * The constructor. |
---|
104 | * |
---|
105 | * @param line the line the error occurred on. |
---|
106 | * @param group the group the error occurred within. |
---|
107 | * @param key the key the error occurred within. |
---|
108 | * @param error the error code. |
---|
109 | * @param detail the details of the error. |
---|
110 | */ |
---|
111 | template<typename D> |
---|
112 | parse_error (size_t line, |
---|
113 | std::string const& group, |
---|
114 | std::string const& key, |
---|
115 | error_type error, |
---|
116 | D const& detail): |
---|
117 | sbuild::error<T>(format_error(line, group, key, error, detail, null(), null()), |
---|
118 | format_reason(line, group, key, error, detail, null(), null())) |
---|
119 | { |
---|
120 | } |
---|
121 | |
---|
122 | /** |
---|
123 | * The constructor. |
---|
124 | * |
---|
125 | * @param group the group the error occurred within. |
---|
126 | * @param error the error code. |
---|
127 | * @param detail the details of the error. |
---|
128 | */ |
---|
129 | template<typename D> |
---|
130 | parse_error (std::string const& group, |
---|
131 | error_type error, |
---|
132 | D const& detail): |
---|
133 | sbuild::error<T>(format_error(group, null(), null(), error, detail, null(), null()), |
---|
134 | format_reason(group, null(), null(), error, detail, null(), null())) |
---|
135 | { |
---|
136 | } |
---|
137 | |
---|
138 | /** |
---|
139 | * The constructor. |
---|
140 | * |
---|
141 | * @param group the group the error occurred within. |
---|
142 | * @param key the key the error occurred within. |
---|
143 | * @param error the error code. |
---|
144 | * @param detail the details of the error. |
---|
145 | */ |
---|
146 | template<typename D> |
---|
147 | parse_error (std::string const& group, |
---|
148 | std::string const& key, |
---|
149 | error_type error, |
---|
150 | D const& detail): |
---|
151 | sbuild::error<T>(format_error(group, key, null(), error, detail, null(), null()), |
---|
152 | format_reason(group, key, null(), error, detail, null(), null())) |
---|
153 | { |
---|
154 | } |
---|
155 | |
---|
156 | /** |
---|
157 | * The constructor. |
---|
158 | * |
---|
159 | * @param context the context of the error. |
---|
160 | * @param error the error. |
---|
161 | */ |
---|
162 | template<typename C> |
---|
163 | parse_error (C const& context, |
---|
164 | std::runtime_error const& error): |
---|
165 | sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null(), null()), |
---|
166 | sbuild::error<T>::format_reason(context, null(), null(), error, null(), null(), null())) |
---|
167 | { |
---|
168 | } |
---|
169 | |
---|
170 | /** |
---|
171 | * The constructor. |
---|
172 | * |
---|
173 | * @param line the line the error occurred on. |
---|
174 | * @param error the error. |
---|
175 | */ |
---|
176 | parse_error (size_t line, |
---|
177 | std::runtime_error const& error): |
---|
178 | sbuild::error<T>(sbuild::error<T>::format_error(line, null(), null(), error, null(), null(), null()), |
---|
179 | sbuild::error<T>::format_reason(line, null(), null(), error, null(), null(), null())) |
---|
180 | { |
---|
181 | } |
---|
182 | |
---|
183 | /** |
---|
184 | * The constructor. |
---|
185 | * |
---|
186 | * @param line the line the error occurred on. |
---|
187 | * @param group the group the error occurred within. |
---|
188 | * @param error the error. |
---|
189 | */ |
---|
190 | parse_error (size_t line, |
---|
191 | std::string const& group, |
---|
192 | std::runtime_error const& error): |
---|
193 | sbuild::error<T>(sbuild::error<T>::format_error(line, group, null(), error, null(), null(), null()), |
---|
194 | sbuild::error<T>::format_reason(line, group, null(), error, null(), null(), null())) |
---|
195 | { |
---|
196 | } |
---|
197 | |
---|
198 | /** |
---|
199 | * The constructor. |
---|
200 | * |
---|
201 | * @param line the line the error occurred on. |
---|
202 | * @param group the group the error occurred within. |
---|
203 | * @param key the key the error occurred within. |
---|
204 | * @param error the error. |
---|
205 | */ |
---|
206 | parse_error (size_t line, |
---|
207 | std::string const& group, |
---|
208 | std::string const& key, |
---|
209 | std::runtime_error const& error): |
---|
210 | sbuild::error<T>(sbuild::error<T>::format_error(line, group, key, error, null(), null(), null()), |
---|
211 | sbuild::error<T>::format_reason(line, group, key, error, null(), null(), null())) |
---|
212 | { |
---|
213 | } |
---|
214 | |
---|
215 | /** |
---|
216 | * The constructor. |
---|
217 | * |
---|
218 | * @param group the group the error occurred within. |
---|
219 | * @param error the error. |
---|
220 | */ |
---|
221 | parse_error (std::string const& group, |
---|
222 | std::runtime_error const& error): |
---|
223 | sbuild::error<T>(sbuild::error<T>::format_error(group, null(), null(), error, null(), null(), null()), |
---|
224 | sbuild::error<T>::format_reason(group, null(), null(), error, null(), null(), null())) |
---|
225 | { |
---|
226 | } |
---|
227 | |
---|
228 | /** |
---|
229 | * The constructor. |
---|
230 | * |
---|
231 | * @param group the group the error occurred within. |
---|
232 | * @param key the key the error occurred within. |
---|
233 | * @param error the error. |
---|
234 | */ |
---|
235 | parse_error (std::string const& group, |
---|
236 | std::string const& key, |
---|
237 | std::runtime_error const& error): |
---|
238 | sbuild::error<T>(sbuild::error<T>::format_error(group, key, null(), error, null(), null(), null()), |
---|
239 | sbuild::error<T>::format_reason(group, key, null(), error, null(), null(), null())) |
---|
240 | { |
---|
241 | } |
---|
242 | |
---|
243 | }; |
---|
244 | |
---|
245 | } |
---|
246 | |
---|
247 | #endif /* SBUILD_PARSE_ERROR_H */ |
---|
248 | |
---|
249 | /* |
---|
250 | * Local Variables: |
---|
251 | * mode:C++ |
---|
252 | * End: |
---|
253 | */ |
---|