sbuild  1.6.10
sbuild-parse-error.h
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 
34  template<typename T>
35  class parse_error : public error<T>
36  {
37  public:
38  typedef typename error<T>::error_type error_type;
39 
46  template<typename C>
47  parse_error (C const& context,
48  error_type error):
49  sbuild::error<T>(this->format_error(context, null(), null(), error, null(), null(), null()),
50  this->format_reason(context, null(), null(), error, null(), null(), null()))
51  {
52  }
53 
60  template<typename D>
61  parse_error (error_type error,
62  D const& detail):
63  sbuild::error<T>(this->format_error(null(), null(), null(), error, detail, null(), null()),
64  this->format_reason(null(), null(), null(), error, detail, null(), null()))
65  {
66  }
67 
75  template<typename D>
76  parse_error (size_t line,
77  error_type error,
78  D const& detail):
79  sbuild::error<T>(this->format_error(line, null(), null(), error, detail, null(), null()),
80  this->format_reason(line, null(), null(), error, detail, null(), null()))
81  {
82  }
83 
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>(this->format_error(line, group, null(), error, detail, null(), null()),
98  this->format_reason(line, group, null(), error, detail, null(), null()))
99  {
100  }
101 
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>(this->format_error(line, group, key, error, detail, null(), null()),
118  this->format_reason(line, group, key, error, detail, null(), null()))
119  {
120  }
121 
129  template<typename D>
130  parse_error (std::string const& group,
131  error_type error,
132  D const& detail):
133  sbuild::error<T>(this->format_error(group, null(), null(), error, detail, null(), null()),
134  this->format_reason(group, null(), null(), error, detail, null(), null()))
135  {
136  }
137 
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>(this->format_error(group, key, null(), error, detail, null(), null()),
152  this->format_reason(group, key, null(), error, detail, null(), null()))
153  {
154  }
155 
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 
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 
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 
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 
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 
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  */
Debian source builder components.
Definition: sbuild-auth-null.h:24
parse_error(error_type error, D const &detail)
The constructor.
Definition: sbuild-parse-error.h:61
parse_error(std::string const &group, std::string const &key, std::runtime_error const &error)
The constructor.
Definition: sbuild-parse-error.h:235
T error_type
The enum type providing the error codes for this type.
Definition: sbuild-error.h:114
parse_error(size_t line, std::string const &group, std::runtime_error const &error)
The constructor.
Definition: sbuild-parse-error.h:190
parse_error(std::string const &group, std::string const &key, error_type error, D const &detail)
The constructor.
Definition: sbuild-parse-error.h:147
parse_error(size_t line, error_type error, D const &detail)
The constructor.
Definition: sbuild-parse-error.h:76
parse_error(std::string const &group, std::runtime_error const &error)
The constructor.
Definition: sbuild-parse-error.h:221
parse_error(size_t line, std::string const &group, error_type error, D const &detail)
The constructor.
Definition: sbuild-parse-error.h:93
Error exception class.
Definition: sbuild-error.h:110
Null.
Definition: sbuild-null.h:33
parse_error(size_t line, std::runtime_error const &error)
The constructor.
Definition: sbuild-parse-error.h:176
parse_error(size_t line, std::string const &group, std::string const &key, error_type error, D const &detail)
The constructor.
Definition: sbuild-parse-error.h:112
parse_error(size_t line, std::string const &group, std::string const &key, std::runtime_error const &error)
The constructor.
Definition: sbuild-parse-error.h:206
parse_error(std::string const &group, error_type error, D const &detail)
The constructor.
Definition: sbuild-parse-error.h:130
Parse error.
Definition: sbuild-parse-error.h:35
System group database entry.
Definition: sbuild-util.h:795
static std::string format_error(A const &context1, B const &context2, C const &context3, error_type error, D const &detail1, E const &detail2, F const &detail3)
Format an error message.
parse_error(C const &context, error_type error)
The constructor.
Definition: sbuild-parse-error.h:47
parse_error(C const &context, std::runtime_error const &error)
The constructor.
Definition: sbuild-parse-error.h:163
static std::string format_reason(A const &context1, B const &context2, C const &context3, R const &error, D const &detail1, E const &detail2, F const &detail3)
Format an reason string.