00001 /* 00002 * Copyright (C) 2004-2007 Marc Boris Duerner 00003 * Copyright (C) 2005-2007 Aloysius Indrayanto 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * As a special exception, you may use this file as part of a free 00011 * software library without restriction. Specifically, if other files 00012 * instantiate templates or use macros or inline functions from this 00013 * file, or you compile this file and link it with other files to 00014 * produce an executable, this file does not by itself cause the 00015 * resulting executable to be covered by the GNU General Public 00016 * License. This exception does not however invalidate any other 00017 * reasons why the executable file might be covered by the GNU Library 00018 * General Public License. 00019 * 00020 * This library is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00023 * Lesser General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU Lesser General Public 00026 * License along with this library; if not, write to the Free Software 00027 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00028 */ 00029 #ifndef CXXTOOLS_SYSTEM_ERROR_H 00030 #define CXXTOOLS_SYSTEM_ERROR_H 00031 00032 #include <stdexcept> 00033 #include <string> 00034 00035 namespace cxxtools 00036 { 00037 00040 class SystemError : public std::runtime_error 00041 { 00042 public: 00043 SystemError(int err, const char* fn); 00044 00045 explicit SystemError(const char* fn); 00046 00047 SystemError(const char* fn, const std::string& msg); 00048 00049 ~SystemError() throw(); 00050 00051 int getErrno() const 00052 { return m_errno; } 00053 00054 private: 00055 int m_errno; 00056 }; 00057 00060 class OpenLibraryFailed : public SystemError 00061 { 00062 std::string _library; 00063 00064 public: 00066 explicit OpenLibraryFailed(const std::string& library); 00067 00069 ~OpenLibraryFailed() throw() 00070 {} 00071 00072 const std::string& library() const 00073 { return _library; } 00074 }; 00075 00078 class SymbolNotFound : public SystemError 00079 { 00080 std::string _symbol; 00081 00082 public: 00083 explicit SymbolNotFound(const std::string& sym); 00084 00086 ~SymbolNotFound() throw() 00087 {} 00088 00090 const std::string& symbol() const 00091 { return _symbol; } 00092 }; 00093 00094 } // namespace cxxtools 00095 00096 #endif