libshevek
src/error.hh
00001 /* error.hh - error and warning handling
00002  * Copyright 2004 Bas Wijnen <wijnen@debian.org>
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation, either version 3 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef SHEVEK_ERROR_HH
00019 #define SHEVEK_ERROR_HH
00020 
00021 #include "iostring.hh"
00022 #include <errno.h>
00023 #include <string.h>
00024 #include <glibmm.h>
00025 
00026 namespace shevek
00027 {
00029 
00031   bool fatal_errors (bool fatal = true);
00033   void _error_impl (Glib::ustring const &msg, bool is_error, char const *file, unsigned line, char const *fun);
00035   #define shevek_error(x) \
00036   shevek::_error_impl ((x), true, __FILE__, __LINE__, __FUNCTION__)
00037 
00038   #define shevek_warning(x) \
00039   shevek::_error_impl ((x), false, __FILE__, __LINE__, __FUNCTION__)
00040 
00041 
00043   #define shevek_error_errno(x) \
00044   shevek::_error_impl (shevek::ostring ("%s: %s", Glib::ustring (x), strerror (errno)), true, __FILE__, __LINE__, __FUNCTION__)
00045 
00046 
00048   #define shevek_warning_errno(x) \
00049   shevek::_error_impl (shevek::ostring ("%s: %s", Glib::ustring (x), strerror (errno)), false, __FILE__, __LINE__, __FUNCTION__)
00050 }
00051 
00052 #endif