sbuild-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_ERROR_H
00021 #define SBUILD_ERROR_H
00022 
00023 #include <map>
00024 #include <stdexcept>
00025 #include <string>
00026 
00027 namespace sbuild
00028 {
00029 
00033   template <typename T>
00034   class error : public std::runtime_error
00035   {
00036   public:
00037     typedef T error_type;
00038     typedef std::map<error_type,const char *> map_type;
00039 
00045     error(std::string const& error):
00046       runtime_error(error)
00047     {
00048     }
00049 
00051     virtual ~error () throw ()
00052     {}
00053 
00054   private:
00056     static map_type error_strings;
00057 
00064     static const char *
00065     get_error (error_type error);
00066 
00067   protected:
00079     template <typename A, typename B, typename C, typename D, typename E>
00080     static std::string
00081     format_error (A const&   context1,
00082                   B const&   context2,
00083                   C const&   context3,
00084                   error_type error,
00085                   D const&   detail1,
00086                   E const&   detail2);
00087 
00099     template <typename A, typename B, typename C, typename D, typename E>
00100     static std::string
00101     format_error (A const&                  context1,
00102                   B const&                  context2,
00103                   C const&                  context3,
00104                   std::runtime_error const& error,
00105                   D const&                  detail1,
00106                   E const&                  detail2);
00107 
00108   };
00109 
00110 }
00111 
00112 #include "sbuild-error.tcc"
00113 
00114 #endif /* SBUILD_ERROR_H */
00115 
00116 /*
00117  * Local Variables:
00118  * mode:C++
00119  * End:
00120  */

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