dbus-cxx logo

error.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007,2008,2009,2010 by Rick L. Vinyard, Jr.             *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the dbus-cxx library.                            *
00006  *                                                                         *
00007  *   The dbus-cxx library is free software; you can redistribute it and/or *
00008  *   modify it under the terms of the GNU General Public License           *
00009  *   version 3 as published by the Free Software Foundation.               *
00010  *                                                                         *
00011  *   The dbus-cxx library is distributed in the hope that it will be       *
00012  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty   *
00013  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014  *   General Public License for more details.                              *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this software. If not see <http://www.gnu.org/licenses/>.  *
00018  ***************************************************************************/
00019 #include <exception>
00020 
00021 #include <dbus-cxx/pointer.h>
00022 
00023 #include <dbus/dbus.h>
00024 
00025 #include <string>
00026 
00027 #ifndef DBUSCXX_ERROR_H
00028 #define DBUSCXX_ERROR_H
00029 
00030 namespace DBus
00031 {
00032 
00033   class Message;
00034 
00051   class Error : public std::exception
00052   {
00053 
00054     protected:
00055    
00056       Error();
00057 
00058       Error( DBusError* cobj );
00059 
00060       Error( const char* name, const char* message=NULL );
00061 
00062       Error( Message& );
00063 
00064     public:
00065       typedef DBusCxxPointer<Error> pointer;
00066 
00067       static pointer create();
00068 
00069       static pointer create( DBusError* cobj );
00070 
00071       static pointer create( const char* name, const char* message );
00072 
00073       static pointer create( Message& );
00074 
00075       ~Error() throw();
00076 
00077       const char* what() const throw();
00078 
00079       const char* name() const;
00080 
00081       const char* message() const;
00082 
00084       void set( const char* name, const char* message );
00085 
00086       bool is_set() const;
00087 
00088       operator bool() const;
00089 
00090 //       Error& operator=( Error& other );
00091 
00092       DBusError* cobj();
00093 
00094     protected:
00095       DBusError m_cobj;
00096 
00097   };
00098 
00099 #define DBUSCXX_ERROR( CPPTYPE, DBUS_ERROR_CODE )            \
00100   class CPPTYPE : public Error {                             \
00101     protected:                                               \
00102     CPPTYPE( const char* message = NULL )                    \
00103         : Error( DBUS_ERROR_CODE, message ) {}               \
00104     public:                                                  \
00105       typedef DBusCxxPointer<CPPTYPE> pointer;               \
00106       static pointer create( const char* message = NULL ) {  \
00107         return pointer( new CPPTYPE(message) );              \
00108       }                                                      \
00109   }
00110 
00116   DBUSCXX_ERROR( ErrorFailed, DBUS_ERROR_FAILED );
00117   
00123   DBUSCXX_ERROR( ErrorNoMemory, DBUS_ERROR_NO_MEMORY );
00124 
00130   DBUSCXX_ERROR( ErrorServiceUnknown, DBUS_ERROR_SERVICE_UNKNOWN );
00131 
00137   DBUSCXX_ERROR( ErrorNameHasNoOwner, DBUS_ERROR_NAME_HAS_NO_OWNER );
00138 
00144   DBUSCXX_ERROR( ErrorNoReply, DBUS_ERROR_NO_REPLY );
00145 
00151   DBUSCXX_ERROR( ErrorIOError, DBUS_ERROR_IO_ERROR );
00152 
00158   DBUSCXX_ERROR( ErrorBadAddress, DBUS_ERROR_BAD_ADDRESS );
00159 
00165   DBUSCXX_ERROR( ErrorNotSupported, DBUS_ERROR_NOT_SUPPORTED );
00166 
00172   DBUSCXX_ERROR( ErrorLimitsExceeded, DBUS_ERROR_LIMITS_EXCEEDED );
00173 
00179   DBUSCXX_ERROR( ErrorAccessDenied, DBUS_ERROR_ACCESS_DENIED );
00180 
00186   DBUSCXX_ERROR( ErrorAuthFailed, DBUS_ERROR_AUTH_FAILED );
00187 
00193   DBUSCXX_ERROR( ErrorNoServer, DBUS_ERROR_NO_SERVER );
00194 
00200   DBUSCXX_ERROR( ErrorTimeout, DBUS_ERROR_TIMEOUT );
00201 
00207   DBUSCXX_ERROR( ErrorNoNetwork, DBUS_ERROR_NO_NETWORK );
00208 
00214   DBUSCXX_ERROR( ErrorAddressInUse, DBUS_ERROR_ADDRESS_IN_USE );
00215 
00221   DBUSCXX_ERROR( ErrorDisconnected, DBUS_ERROR_DISCONNECTED );
00222 
00228   DBUSCXX_ERROR( ErrorInvalidArgs, DBUS_ERROR_INVALID_ARGS );
00229 
00235   DBUSCXX_ERROR( ErrorFileNotFound, DBUS_ERROR_FILE_NOT_FOUND );
00236 
00242   DBUSCXX_ERROR( ErrorFileExists, DBUS_ERROR_FILE_EXISTS );
00243 
00249   DBUSCXX_ERROR( ErrorUnknownMethod, DBUS_ERROR_UNKNOWN_METHOD );
00250 
00256   DBUSCXX_ERROR( ErrorTimedOut, DBUS_ERROR_TIMED_OUT );
00257 
00263   DBUSCXX_ERROR( ErrorMatchRuleNotFound, DBUS_ERROR_MATCH_RULE_NOT_FOUND );
00264 
00270   DBUSCXX_ERROR( ErrorMatchRuleInvalid, DBUS_ERROR_MATCH_RULE_INVALID );
00271 
00277   DBUSCXX_ERROR( ErrorSpawnExecFailed, DBUS_ERROR_SPAWN_EXEC_FAILED );
00278 
00284   DBUSCXX_ERROR( ErrorSpawnForkFailed, DBUS_ERROR_SPAWN_FORK_FAILED );
00285 
00291   DBUSCXX_ERROR( ErrorSpawnChildExited, DBUS_ERROR_SPAWN_CHILD_EXITED );
00292 
00298   DBUSCXX_ERROR( ErrorSpawnChildSignaled, DBUS_ERROR_SPAWN_CHILD_SIGNALED );
00299 
00305   DBUSCXX_ERROR( ErrorSpawnFailed, DBUS_ERROR_SPAWN_FAILED );
00306 
00312   DBUSCXX_ERROR( ErrorUnixProcessIdUnknown, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN );
00313 
00319   DBUSCXX_ERROR( ErrorInvalidSignature, DBUS_ERROR_INVALID_SIGNATURE );
00320 
00326   DBUSCXX_ERROR( ErrorInvalidFileContent, DBUS_ERROR_INVALID_FILE_CONTENT );
00327 
00333   DBUSCXX_ERROR( ErrorSELinuxSecurityContextUnknown, DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN );
00334 
00340   DBUSCXX_ERROR( ErrorInvalidCObject, "Invalid C Object" );
00341 
00347   DBUSCXX_ERROR( ErrorInvalidTypecast, "Invalid Typecast" );
00348 
00354   DBUSCXX_ERROR( ErrorInvalidConnection, "DBus connection is invalid" );
00355 
00361   DBUSCXX_ERROR( ErrorInvalidMessageType, "DBus message type does not match the C++ Message object type" );
00362 
00368   DBUSCXX_ERROR( ErrorNoConnection, "No connection specified and operation requires a DBus connection" );
00369 
00375   DBUSCXX_ERROR( ErrorDeadlock, "Locking a mutex a dbus-cxx thread already owns" );
00376 
00382   DBUSCXX_ERROR( ErrorNotOwner, "Unlocking a mutex a dbus-cxx thread doesn't own" );
00383 
00389   DBUSCXX_ERROR( ErrorNotInitialized, "DBus::init(bool threadsafe=true) not called" );
00390 
00396   DBUSCXX_ERROR( ErrorInvalidAdaptee, "DBus adapter method called, but adaptee is invalid" );
00397 
00398 }
00399 
00400 #endif

Generated on Thu Mar 18 09:30:54 2010 for dbus-cxx by doxygen 1.6.1