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 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:
00037     typedef typename error<T>::error_type error_type;
00038 
00044     custom_error (error_type error):
00045       sbuild::error<T>(format_error(null(), null(), null(), error, null(), null()),
00046                        format_reason(null(), null(), null(), error, null(), null()))
00047     {
00048     }
00049 
00056     template<typename C>
00057     custom_error (C const&   context,
00058                   error_type error):
00059       sbuild::error<T>(format_error(context, null(), null(), error, null(), null()),
00060                        format_reason(context, null(), null(), error, null(), null()))
00061     {
00062     }
00063 
00070     template<typename D>
00071     custom_error (error_type error,
00072                   D const&   detail):
00073       sbuild::error<T>(format_error(null(), null(), null(), error, detail, null()),
00074                        format_reason(null(), null(), null(), error, detail, null()))
00075     {
00076     }
00077 
00085     template<typename D, typename E>
00086     custom_error (error_type error,
00087                   D const&   detail,
00088                   E const&   detail2):
00089       sbuild::error<T>(format_error(null(), null(), null(), error, detail, detail2),
00090                        format_reason(null(), null(), null(), error, detail, detail2))
00091     {
00092     }
00093 
00101     template<typename C, typename D>
00102     custom_error (C const&   context,
00103                   error_type error,
00104                   D const&   detail):
00105       sbuild::error<T>(format_error(context, null(), null(), error, detail, null()),
00106                        format_reason(context, null(), null(), error, detail, null()))
00107     {
00108     }
00109 
00118     template<typename C, typename D, typename E>
00119     custom_error (C const&   context,
00120                   error_type error,
00121                   D const&   detail,
00122                   E const&   detail2):
00123       sbuild::error<T>(format_error(context, null(), null(), error, detail, detail2),
00124                        format_reason(context, null(), null(), error, detail, detail2))
00125     {
00126     }
00127 
00136     template<typename C, typename D, typename E>
00137     custom_error (C const&   context1,
00138                   D const&   context2,
00139                   error_type error,
00140                   E const&   detail):
00141       sbuild::error<T>(format_error(context1, context2, null(), error, detail, null()),
00142                        format_reason(context1, context2, null(), error, detail, null()))
00143     {
00144     }
00145 
00155     template<typename C, typename D, typename E, typename F>
00156     custom_error (C const&   context1,
00157                   D const&   context2,
00158                   error_type error,
00159                   E const&   detail,
00160                   F const&   detail2):
00161       sbuild::error<T>(format_error(context1, context2, null(), error, detail, detail2),
00162                        format_reason(context1, context2, null(), error, detail, detail2))
00163     {
00164     }
00165 
00171     custom_error (std::runtime_error const& error):
00172       sbuild::error<T>(sbuild::error<T>::format_error(null(), null(), null(), error, null(), null()),
00173                        sbuild::error<T>::format_reason(null(), null(), null(), error, null(), null()))
00174     {
00175     }
00176 
00182     custom_error (error_base const& error):
00183       sbuild::error<T>(sbuild::error<T>::format_error(null(), null(), null(), error, null(), null()),
00184                        sbuild::error<T>::format_reason(null(), null(), null(), error, null(), null()))
00185     {
00186     }
00187 
00194     template<typename C>
00195     custom_error (C const&                  context,
00196                   std::runtime_error const& error):
00197       sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null()),
00198                        sbuild::error<T>::format_reason(context, null(), null(), error, null(), null()))
00199     {
00200     }
00201 
00208     template<typename C>
00209     custom_error (C const&          context,
00210                   error_base const& error):
00211       sbuild::error<T>(sbuild::error<T>::format_error(context, null(), null(), error, null(), null()),
00212                        sbuild::error<T>::format_reason(context, null(), null(), error, null(), null()))
00213     {
00214     }
00215 
00217     virtual ~custom_error () throw ()
00218     {}
00219   };
00220 
00221 }
00222 
00223 #endif /* SBUILD_CUSTOM_ERROR_H */
00224 
00225 /*
00226  * Local Variables:
00227  * mode:C++
00228  * End:
00229  */

Generated on Sun Jul 8 21:23:22 2007 for sbuild by  doxygen 1.5.2