dbus-cxx logo

error.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007,2008,2009 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 #ifndef DBUSCXX_ERROR_H
00020 #define DBUSCXX_ERROR_H
00021 
00022 #include <exception>
00023 
00024 #include <dbus-cxx/pointer.h>
00025 
00026 #include <dbus/dbus.h>
00027 
00028 #include <string>
00029 
00030 namespace DBus
00031 {
00032 
00033   class Message;
00034 
00051   class Error : public std::exception
00052   {
00053     public:
00054       typedef DBusCxxPointer<Error> pointer;
00055 
00056       Error();
00057 
00058       Error( DBusError* cobj );
00059 
00060       Error( const char* name, const char* message=NULL );
00061 
00062       Error( Message& );
00063 
00064       pointer create();
00065 
00066       pointer create( DBusError* cobj );
00067 
00068       pointer create( const char* name, const char* message );
00069 
00070       ~Error() throw();
00071 
00072       const char* what() const throw();
00073 
00074       const char* name() const;
00075 
00076       const char* message() const;
00077 
00079       void set( const char* name, const char* message );
00080 
00081       bool is_set() const;
00082 
00083       operator bool() const;
00084 
00085       Error& operator=( Error& other );
00086 
00087       DBusError* cobj();
00088 
00089     protected:
00090       DBusError m_cobj;
00091 
00092   };
00093 
00094 #define DBUSCXX_ERROR( CPPTYPE, DBUS_ERROR_CODE ) \
00095   struct CPPTYPE : public Error {                 \
00096     CPPTYPE( const char* message = NULL )         \
00097         : Error( DBUS_ERROR_CODE, message ) {}    \
00098   }
00099 
00105   DBUSCXX_ERROR( ErrorFailed, DBUS_ERROR_FAILED );
00106   
00112   DBUSCXX_ERROR( ErrorNoMemory, DBUS_ERROR_NO_MEMORY );
00113 
00119   DBUSCXX_ERROR( ErrorServiceUnknown, DBUS_ERROR_SERVICE_UNKNOWN );
00120 
00126   DBUSCXX_ERROR( ErrorNameHasNoOwner, DBUS_ERROR_NAME_HAS_NO_OWNER );
00127 
00133   DBUSCXX_ERROR( ErrorNoReply, DBUS_ERROR_NO_REPLY );
00134 
00140   DBUSCXX_ERROR( ErrorIOError, DBUS_ERROR_IO_ERROR );
00141 
00147   DBUSCXX_ERROR( ErrorBadAddress, DBUS_ERROR_BAD_ADDRESS );
00148 
00154   DBUSCXX_ERROR( ErrorNotSupported, DBUS_ERROR_NOT_SUPPORTED );
00155 
00161   DBUSCXX_ERROR( ErrorLimitsExceeded, DBUS_ERROR_LIMITS_EXCEEDED );
00162 
00168   DBUSCXX_ERROR( ErrorAccessDenied, DBUS_ERROR_ACCESS_DENIED );
00169 
00175   DBUSCXX_ERROR( ErrorAuthFailed, DBUS_ERROR_AUTH_FAILED );
00176 
00182   DBUSCXX_ERROR( ErrorNoServer, DBUS_ERROR_NO_SERVER );
00183 
00189   DBUSCXX_ERROR( ErrorTimeout, DBUS_ERROR_TIMEOUT );
00190 
00196   DBUSCXX_ERROR( ErrorNoNetwork, DBUS_ERROR_NO_NETWORK );
00197 
00203   DBUSCXX_ERROR( ErrorAddressInUse, DBUS_ERROR_ADDRESS_IN_USE );
00204 
00210   DBUSCXX_ERROR( ErrorDisconnected, DBUS_ERROR_DISCONNECTED );
00211 
00217   DBUSCXX_ERROR( ErrorInvalidArgs, DBUS_ERROR_INVALID_ARGS );
00218 
00224   DBUSCXX_ERROR( ErrorFileNotFound, DBUS_ERROR_FILE_NOT_FOUND );
00225 
00231   DBUSCXX_ERROR( ErrorFileExists, DBUS_ERROR_FILE_EXISTS );
00232 
00238   DBUSCXX_ERROR( ErrorUnknownMethod, DBUS_ERROR_UNKNOWN_METHOD );
00239 
00245   DBUSCXX_ERROR( ErrorTimedOut, DBUS_ERROR_TIMED_OUT );
00246 
00252   DBUSCXX_ERROR( ErrorMatchRuleNotFound, DBUS_ERROR_MATCH_RULE_NOT_FOUND );
00253 
00259   DBUSCXX_ERROR( ErrorMatchRuleInvalid, DBUS_ERROR_MATCH_RULE_INVALID );
00260 
00266   DBUSCXX_ERROR( ErrorSpawnExecFailed, DBUS_ERROR_SPAWN_EXEC_FAILED );
00267 
00273   DBUSCXX_ERROR( ErrorSpawnForkFailed, DBUS_ERROR_SPAWN_FORK_FAILED );
00274 
00280   DBUSCXX_ERROR( ErrorSpawnChildExited, DBUS_ERROR_SPAWN_CHILD_EXITED );
00281 
00287   DBUSCXX_ERROR( ErrorSpawnChildSignaled, DBUS_ERROR_SPAWN_CHILD_SIGNALED );
00288 
00294   DBUSCXX_ERROR( ErrorSpawnFailed, DBUS_ERROR_SPAWN_FAILED );
00295 
00301   DBUSCXX_ERROR( ErrorUnixProcessIdUnknown, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN );
00302 
00308   DBUSCXX_ERROR( ErrorInvalidSignature, DBUS_ERROR_INVALID_SIGNATURE );
00309 
00315   DBUSCXX_ERROR( ErrorInvalidFileContent, DBUS_ERROR_INVALID_FILE_CONTENT );
00316 
00322   DBUSCXX_ERROR( ErrorSELinuxSecurityContextUnknown, DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN );
00323 
00329   DBUSCXX_ERROR( ErrorInvalidCObject, "Invalid C Object" );
00330 
00336   DBUSCXX_ERROR( ErrorInvalidTypecast, "Invalid Typecast" );
00337 
00343   DBUSCXX_ERROR( ErrorInvalidConnection, "DBus connection is invalid" );
00344 
00350   DBUSCXX_ERROR( ErrorInvalidMessageType, "DBus message type does not match the C++ Message object type" );
00351 
00357   DBUSCXX_ERROR( ErrorNoConnection, "No connection specified and operation requires a DBus connection" );
00358 
00364   DBUSCXX_ERROR( ErrorDeadlock, "Locking a mutex a dbus-cxx thread already owns" );
00365 
00371   DBUSCXX_ERROR( ErrorNotOwner, "Unlocking a mutex a dbus-cxx thread doesn't own" );
00372 
00378   DBUSCXX_ERROR( ErrorNotInitialized, "DBus::init(bool threadsafe=true) not called" );
00379 
00385   DBUSCXX_ERROR( ErrorInvalidAdaptee, "DBus adapter method called, but adaptee is invalid" );
00386 
00387 }
00388 
00389 #endif

Generated on Mon Sep 21 10:59:27 2009 for dbus-cxx by doxygen 1.6.1