sbuild-custom-error.h

Go to the documentation of this file.
00001 /* Copyright © 2005-2006  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 2 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, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00016  * MA  02111-1307  USA
00017  *
00018  *********************************************************************/
00019 
00020 #ifndef SBUILD_CUSTOM_ERROR_H
00021 #define SBUILD_CUSTOM_ERROR_H
00022 
00023 #include <sbuild/sbuild-error.h>
00024 #include <sbuild/sbuild-null.h>
00025 
00026 namespace sbuild
00027 {
00028 
00032   template <typename T>
00033   class custom_error : public error<T>
00034   {
00035   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     {
00046     }
00047 
00054     template<typename C>
00055     custom_error (C const&   context,
00056                   error_type error):
00057       sbuild::error<T>(format_error(context, null(), null(), error, null(), null()))
00058     {
00059     }
00060 
00067     template<typename D>
00068     custom_error (error_type error,
00069                   D const&   detail):
00070       sbuild::error<T>(format_error(null(), null(), null(), error, detail, null()))
00071     {
00072     }
00073 
00081     template<typename D, typename E>
00082     custom_error (error_type error,
00083                   D const&   detail,
00084                   E const&   detail2):
00085       sbuild::error<T>(format_error(null(), null(), null(), error, detail, detail2))
00086     {
00087     }
00088 
00096     template<typename C, typename D>
00097     custom_error (C const&   context,
00098                   error_type error,
00099                   D const&   detail):
00100       sbuild::error<T>(format_error(context, null(), null(), error, detail, null()))
00101     {
00102     }
00103 
00112     template<typename C, typename D, typename E>
00113     custom_error (C const&   context,
00114                   error_type error,
00115                   D const&   detail,
00116                   E const&   detail2):
00117       sbuild::error<T>(format_error(context, null(), null(), error, detail, detail2))
00118     {
00119     }
00120 
00126     custom_error (std::runtime_error const& error):
00127       sbuild::error<T>(sbuild::error<T>::format_error(null(), null(), null(), error, null(), null()))
00128     {
00129     }
00130 
00137     template<typename C>
00138     custom_error (C const&                  context,
00139                   std::runtime_error const& error):
00140       sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null()))
00141     {
00142     }
00143 
00145     virtual ~custom_error () throw ()
00146     {}
00147   };
00148 
00149 }
00150 
00151 #endif /* SBUILD_CUSTOM_ERROR_H */
00152 
00153 /*
00154  * Local Variables:
00155  * mode:C++
00156  * End:
00157  */

Generated on Fri Jul 14 19:52:17 2006 for schroot by  doxygen 1.4.7