diff options
author | Bill Allombert <ballombe@debian.org> | 2011-11-16 12:33:27 +0100 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-03-05 16:39:28 +0000 |
commit | dd7279795c97aa356727d366a2149c9bc838b496 (patch) | |
tree | a87d19d2e5220f5b38aec3b5b036235a59f971c9 /update-menus/exceptions.h | |
download | menu-dd7279795c97aa356727d366a2149c9bc838b496.tar.gz |
Imported Debian version 2.1.46debian/2.1.46
Diffstat (limited to 'update-menus/exceptions.h')
-rw-r--r-- | update-menus/exceptions.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/update-menus/exceptions.h b/update-menus/exceptions.h new file mode 100644 index 0000000..f4c818d --- /dev/null +++ b/update-menus/exceptions.h @@ -0,0 +1,102 @@ +/* + * Debian menu system -- update-menus and install-menu + * update-menus/exceptions.h + * + * Copyright (C) 1996-2003 Joost Witteveen, + * Copyright (C) 2002-2004 Bill Allombert and Morten Brix Pedersen. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License with + * the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + * + * Written by Joost Witteveen. + */ + +#ifndef EXCEPTIONS_H +#define EXCEPTIONS_H + +#include <string> +#include <iostream> +#include "common.h" +#include "compose.hpp" + +namespace exceptions { + /** Base class for general exceptions */ + class genexcept { + public: + virtual void report() { + std::cerr << message() << std::endl; + } + virtual std::string message() const { + return _("Unknown error."); + } + virtual ~genexcept() { } + }; + + /** Base exception class for classes returning string error messages */ + class except_string : public genexcept { + protected: + std::string msg; + public: + except_string(std::string s) : msg(s) { } + std::string message() const { + return String::compose(_("Unknown error, message=%1"), msg); + } + }; + + /** Exception class to be thrown when a file fails to open */ + class ferror_open : public except_string { + public: + ferror_open(std::string s):except_string(s) { } + std::string message() const { + return String::compose(_("Unable to open file \"%1\"."), msg); + } + }; + + /** Exception class to be thrown when opening a pipe for reading */ + class pipeerror_read : public except_string { + public: + pipeerror_read(std::string s) : except_string(s) { } + std::string message() { + return String::compose(_("Failed to pipe data through \"%1\" (pipe opened for reading)."), msg); + } + }; + + /** Exception class to be thrown when a fatal error occured */ + class informed_fatal : public genexcept { + public: + std::string message() const { return ""; } + }; + + /** Exception to be thrown when a required tag is missing */ + class missing_tag : public except_string { + std::string file; + public: + missing_tag(std::string f, std::string s) : except_string(s), file(f) { } + std::string message() { + return String::compose(_("%1: missing required tag: \"%2\""), file, msg); + } + }; + + /** Exception to be thrown when package isn't installed. */ + class cond_inst_false : public genexcept { }; + + /** Exception to be thrown when opening a directory failed */ + class dir_error_read : public genexcept { }; + +} + + +#endif /* EXCEPTIONS_H */ |