sbuild-custom-error.h

Go to the documentation of this file.
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()),
00045                        format_reason(null(), null(), null(), error, 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()),
00059                        format_reason(context, null(), null(), error, 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()),
00073                        format_reason(null(), null(), null(), error, detail, 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),
00089                        format_reason(null(), null(), null(), error, detail, detail2))
00090     {
00091     }
00092 
00100     template<typename C, typename D>
00101     custom_error (C const&   context,
00102                   error_type error,
00103                   D const&   detail):
00104       sbuild::error<T>(format_error(context, null(), null(), error, detail, null()),
00105                        format_reason(context, null(), null(), error, detail, null()))
00106     {
00107     }
00108 
00117     template<typename C, typename D, typename E>
00118     custom_error (C const&   context,
00119                   error_type error,
00120                   D const&   detail,
00121                   E const&   detail2):
00122       sbuild::error<T>(format_error(context, null(), null(), error, detail, detail2),
00123                        format_reason(context, null(), null(), error, detail, detail2))
00124     {
00125     }
00126 
00135     template<typename C, typename D, typename E>
00136     custom_error (C const&   context1,
00137                   D const&   context2,
00138                   error_type error,
00139                   E const&   detail):
00140       sbuild::error<T>(format_error(context1, context2, null(), error, detail, null()),
00141                        format_reason(context1, context2, null(), error, detail, null()))
00142     {
00143     }
00144 
00154     template<typename C, typename D, typename E, typename F>
00155     custom_error (C const&   context1,
00156                   D const&   context2,
00157                   error_type error,
00158                   E const&   detail,
00159                   F const&   detail2):
00160       sbuild::error<T>(format_error(context1, context2, null(), error, detail, detail2),
00161                        format_reason(context1, context2, null(), error, detail, detail2))
00162     {
00163     }
00164 
00170     custom_error (std::runtime_error const& error):
00171       sbuild::error<T>(sbuild::error<T>::format_error(null(), null(), null(), error, null(), null()),
00172                        sbuild::error<T>::format_reason(null(), null(), null(), error, null(), null()))
00173     {
00174     }
00175 
00181     custom_error (error_base const& error):
00182       sbuild::error<T>(sbuild::error<T>::format_error(null(), null(), null(), error, null(), null()),
00183                        sbuild::error<T>::format_reason(null(), null(), null(), error, null(), null()))
00184     {
00185     }
00186 
00193     template<typename C>
00194     custom_error (C const&                  context,
00195                   std::runtime_error const& error):
00196       sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null()),
00197                        sbuild::error<T>::format_reason(context, null(), null(), error, null(), null()))
00198     {
00199     }
00200 
00207     template<typename C>
00208     custom_error (C const&          context,
00209                   error_base const& error):
00210       sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null()),
00211                        sbuild::error<T>::format_reason(context, null(), null(), error, null(), null()))
00212     {
00213     }
00214 
00216     virtual ~custom_error () throw ()
00217     {}
00218   };
00219 
00220 }
00221 
00222 #endif /* SBUILD_CUSTOM_ERROR_H */
00223 
00224 /*
00225  * Local Variables:
00226  * mode:C++
00227  * End:
00228  */

Generated on Sun Mar 22 22:18:14 2009 for sbuild by  doxygen 1.5.8