sbuild  1.6.10
sbuild-custom-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_CUSTOM_ERROR_H
20 #define SBUILD_CUSTOM_ERROR_H
21 
22 #include <sbuild/sbuild-error.h>
23 #include <sbuild/sbuild-null.h>
24 
25 namespace sbuild
26 {
27 
31  template <typename T>
32  class custom_error : public error<T>
33  {
34  public:
36  typedef typename error<T>::error_type error_type;
37 
43  custom_error (error_type error):
44  sbuild::error<T>(this->format_error(null(), null(), null(), error, null(), null(), null()),
45  this->format_reason(null(), null(), null(), error, null(), null(), null()))
46  {
47  }
48 
55  template<typename C>
56  custom_error (C const& context,
57  error_type error):
58  sbuild::error<T>(this->format_error(context, null(), null(), error, null(), null(), null()),
59  this->format_reason(context, null(), null(), error, null(), null(), null()))
60  {
61  }
62 
69  template<typename D>
70  custom_error (error_type error,
71  D const& detail):
72  sbuild::error<T>(this->format_error(null(), null(), null(), error, detail, null(), null()),
73  this->format_reason(null(), null(), null(), error, detail, null(), null()))
74  {
75  }
76 
84  template<typename D, typename E>
85  custom_error (error_type error,
86  D const& detail,
87  E const& detail2):
88  sbuild::error<T>(this->format_error(null(), null(), null(), error, detail, detail2, null()),
89  this->format_reason(null(), null(), null(), error, detail, detail2, null()))
90  {
91  }
92 
101  template<typename D, typename E, typename F>
102  custom_error (error_type error,
103  D const& detail,
104  E const& detail2,
105  F const& detail3):
106  sbuild::error<T>(this->format_error(null(), null(), null(), error, detail, detail2, detail3),
107  this->format_reason(null(), null(), null(), error, detail, detail2, detail3))
108  {
109  }
110 
118  template<typename C, typename D>
119  custom_error (C const& context,
120  error_type error,
121  D const& detail):
122  sbuild::error<T>(this->format_error(context, null(), null(), error, detail, null(), null()),
123  this->format_reason(context, null(), null(), error, detail, null(), null()))
124  {
125  }
126 
135  template<typename C, typename D, typename E>
136  custom_error (C const& context,
137  error_type error,
138  D const& detail,
139  E const& detail2):
140  sbuild::error<T>(format_error(context, null(), null(), error, detail, detail2, null()),
141  format_reason(context, null(), null(), error, detail, detail2, null()))
142  {
143  }
144 
153  template<typename C, typename D, typename E>
154  custom_error (C const& context1,
155  D const& context2,
156  error_type error,
157  E const& detail):
158  sbuild::error<T>(this->format_error(context1, context2, null(), error, detail, null(), null()),
159  this->format_reason(context1, context2, null(), error, detail, null(), null()))
160  {
161  }
162 
172  template<typename C, typename D, typename E, typename F>
173  custom_error (C const& context1,
174  D const& context2,
175  error_type error,
176  E const& detail,
177  F const& detail2):
178  sbuild::error<T>(format_error(context1, context2, null(), error, detail, detail2, null()),
179  format_reason(context1, context2, null(), error, detail, detail2, null()))
180  {
181  }
182 
188  custom_error (std::runtime_error const& error):
189  sbuild::error<T>(sbuild::error<T>::format_error(null(), null(), null(), error, null(), null(), null()),
190  sbuild::error<T>::format_reason(null(), null(), null(), error, null(), null(), null()))
191  {
192  }
193 
200  sbuild::error<T>(sbuild::error<T>::format_error(null(), null(), null(), error, null(), null(), null()),
201  sbuild::error<T>::format_reason(null(), null(), null(), error, null(), null(), null()))
202  {
203  }
204 
211  template<typename C>
212  custom_error (C const& context,
213  std::runtime_error const& error):
214  sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null(), null()),
215  sbuild::error<T>::format_reason(context, null(), null(), error, null(), null(), null()))
216  {
217  }
218 
225  template<typename C>
226  custom_error (C const& context,
227  error_base const& error):
228  sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null(), null()),
229  sbuild::error<T>::format_reason(context, null(), null(), error, null(), null(), null()))
230  {
231  }
232 
234  virtual ~custom_error () throw ()
235  {}
236  };
237 
238 }
239 
240 #endif /* SBUILD_CUSTOM_ERROR_H */
241 
242 /*
243  * Local Variables:
244  * mode:C++
245  * End:
246  */
custom_error(error_type error, D const &detail)
The constructor.
Definition: sbuild-custom-error.h:70
error< T >::error_type error_type
The enum type providing the error codes for this type.
Definition: sbuild-custom-error.h:36
Debian source builder components.
Definition: sbuild-auth-null.h:24
custom_error(C const &context, error_type error, D const &detail)
The constructor.
Definition: sbuild-custom-error.h:119
T error_type
The enum type providing the error codes for this type.
Definition: sbuild-error.h:114
custom_error(error_base const &error)
The constructor.
Definition: sbuild-custom-error.h:199
custom_error(error_type error, D const &detail, E const &detail2)
The constructor.
Definition: sbuild-custom-error.h:85
custom_error(C const &context, error_type error)
The constructor.
Definition: sbuild-custom-error.h:56
Error exception base class.
Definition: sbuild-error.h:36
custom_error(C const &context1, D const &context2, error_type error, E const &detail, F const &detail2)
The constructor.
Definition: sbuild-custom-error.h:173
custom_error(error_type error)
The constructor.
Definition: sbuild-custom-error.h:43
custom_error(C const &context, error_base const &error)
The constructor.
Definition: sbuild-custom-error.h:226
Error exception class.
Definition: sbuild-error.h:110
Null.
Definition: sbuild-null.h:33
custom_error(C const &context, std::runtime_error const &error)
The constructor.
Definition: sbuild-custom-error.h:212
custom_error(C const &context, error_type error, D const &detail, E const &detail2)
The constructor.
Definition: sbuild-custom-error.h:136
Custom error.
Definition: sbuild-custom-error.h:32
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.
custom_error(C const &context1, D const &context2, error_type error, E const &detail)
The constructor.
Definition: sbuild-custom-error.h:154
virtual ~custom_error()
The destructor.
Definition: sbuild-custom-error.h:234
custom_error(std::runtime_error const &error)
The constructor.
Definition: sbuild-custom-error.h:188
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.
custom_error(error_type error, D const &detail, E const &detail2, F const &detail3)
The constructor.
Definition: sbuild-custom-error.h:102