NetLink Sockets C++ 1.0.0
Networking C++ Library @ Get NetLink Sockets C++ Library at SourceForge.net. Fast, secure and Free Open Source software downloads

include/netlink/exception.h

00001 /*
00002     NetLink Sockets: Networking C++ library
00003     Copyright 2012 Pedro Francisco Pareja Ruiz (PedroPareja@Gmail.com)
00004 
00005     This file is part of NetLink Sockets.
00006 
00007     NetLink Sockets is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     NetLink Sockets is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with NetLink Sockets. If not, see <http://www.gnu.org/licenses/>.
00019 
00020 */
00021 
00022 #ifndef __NL_EXCEPTION
00023 #define __NL_EXCEPTION
00024 
00025 #include "netlink/core.h"
00026 
00027 NL_NAMESPACE
00028 
00036 class Exception {
00037 
00038     public:
00039 
00040         enum CODE {
00041             #include "netlink/exception.code.inc"
00042         };
00043 
00044     private:
00045 
00046         CODE    _code;
00047         string  _msg;
00048         int     _nativeErrorCode;
00049 
00050     public:
00051 
00052         Exception(CODE code, const string& msg, int nativeErrorCode = 0): _code(code), _msg(msg), _nativeErrorCode(nativeErrorCode) {}
00053 
00081         CODE code() const           { return _code; }
00082 
00083 
00090         const string& msg() const   { return _msg; }
00091 
00098         const char* what() const    { return _msg.c_str(); }
00099 
00100 
00108         int nativeErrorCode() const { return _nativeErrorCode; }
00109 };
00110 
00111 NL_NAMESPACE_END
00112 
00113 #endif
 All Classes Namespaces Files Functions Enumerations Enumerator