sbuild 1.4.23
|
00001 /* Copyright © 2005-2007 Roger Leigh <rleigh@debian.org> 00002 * 00003 * schroot is free software: you can redistribute it and/or modify it 00004 * under the terms of the GNU General Public License as published by 00005 * the Free Software Foundation, either version 3 of the License, or 00006 * (at your option) any later version. 00007 * 00008 * schroot is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program. If not, see 00015 * <http://www.gnu.org/licenses/>. 00016 * 00017 *********************************************************************/ 00018 00019 #ifndef SBUILD_CUSTOM_ERROR_H 00020 #define SBUILD_CUSTOM_ERROR_H 00021 00022 #include <sbuild/sbuild-error.h> 00023 #include <sbuild/sbuild-null.h> 00024 00025 namespace sbuild 00026 { 00027 00031 template <typename T> 00032 class custom_error : public error<T> 00033 { 00034 public: 00036 typedef typename error<T>::error_type error_type; 00037 00043 custom_error (error_type error): 00044 sbuild::error<T>(format_error(null(), null(), null(), error, null(), null(), null()), 00045 format_reason(null(), null(), null(), error, null(), null(), null())) 00046 { 00047 } 00048 00055 template<typename C> 00056 custom_error (C const& context, 00057 error_type error): 00058 sbuild::error<T>(format_error(context, null(), null(), error, null(), null(), null()), 00059 format_reason(context, null(), null(), error, null(), null(), null())) 00060 { 00061 } 00062 00069 template<typename D> 00070 custom_error (error_type error, 00071 D const& detail): 00072 sbuild::error<T>(format_error(null(), null(), null(), error, detail, null(), null()), 00073 format_reason(null(), null(), null(), error, detail, null(), null())) 00074 { 00075 } 00076 00084 template<typename D, typename E> 00085 custom_error (error_type error, 00086 D const& detail, 00087 E const& detail2): 00088 sbuild::error<T>(format_error(null(), null(), null(), error, detail, detail2, null()), 00089 format_reason(null(), null(), null(), error, detail, detail2, null())) 00090 { 00091 } 00092 00101 template<typename D, typename E, typename F> 00102 custom_error (error_type error, 00103 D const& detail, 00104 E const& detail2, 00105 F const& detail3): 00106 sbuild::error<T>(format_error(null(), null(), null(), error, detail, detail2, detail3), 00107 format_reason(null(), null(), null(), error, detail, detail2, detail3)) 00108 { 00109 } 00110 00118 template<typename C, typename D> 00119 custom_error (C const& context, 00120 error_type error, 00121 D const& detail): 00122 sbuild::error<T>(format_error(context, null(), null(), error, detail, null(), null()), 00123 format_reason(context, null(), null(), error, detail, null(), null())) 00124 { 00125 } 00126 00135 template<typename C, typename D, typename E> 00136 custom_error (C const& context, 00137 error_type error, 00138 D const& detail, 00139 E const& detail2): 00140 sbuild::error<T>(format_error(context, null(), null(), error, detail, detail2, null()), 00141 format_reason(context, null(), null(), error, detail, detail2, null())) 00142 { 00143 } 00144 00153 template<typename C, typename D, typename E> 00154 custom_error (C const& context1, 00155 D const& context2, 00156 error_type error, 00157 E const& detail): 00158 sbuild::error<T>(format_error(context1, context2, null(), error, detail, null(), null()), 00159 format_reason(context1, context2, null(), error, detail, null(), null())) 00160 { 00161 } 00162 00172 template<typename C, typename D, typename E, typename F> 00173 custom_error (C const& context1, 00174 D const& context2, 00175 error_type error, 00176 E const& detail, 00177 F const& detail2): 00178 sbuild::error<T>(format_error(context1, context2, null(), error, detail, detail2, null()), 00179 format_reason(context1, context2, null(), error, detail, detail2, null())) 00180 { 00181 } 00182 00188 custom_error (std::runtime_error const& error): 00189 sbuild::error<T>(sbuild::error<T>::format_error(null(), null(), null(), error, null(), null(), null()), 00190 sbuild::error<T>::format_reason(null(), null(), null(), error, null(), null(), null())) 00191 { 00192 } 00193 00199 custom_error (error_base const& error): 00200 sbuild::error<T>(sbuild::error<T>::format_error(null(), null(), null(), error, null(), null(), null()), 00201 sbuild::error<T>::format_reason(null(), null(), null(), error, null(), null(), null())) 00202 { 00203 } 00204 00211 template<typename C> 00212 custom_error (C const& context, 00213 std::runtime_error const& error): 00214 sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null(), null()), 00215 sbuild::error<T>::format_reason(context, null(), null(), error, null(), null(), null())) 00216 { 00217 } 00218 00225 template<typename C> 00226 custom_error (C const& context, 00227 error_base const& error): 00228 sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null(), null()), 00229 sbuild::error<T>::format_reason(context, null(), null(), error, null(), null(), null())) 00230 { 00231 } 00232 00234 virtual ~custom_error () throw () 00235 {} 00236 }; 00237 00238 } 00239 00240 #endif /* SBUILD_CUSTOM_ERROR_H */ 00241 00242 /* 00243 * Local Variables: 00244 * mode:C++ 00245 * End: 00246 */