dbus-cxx logo
error.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2007,2008,2009,2010 by Rick L. Vinyard, Jr. *
3  * rvinyard@cs.nmsu.edu *
4  * *
5  * This file is part of the dbus-cxx library. *
6  * *
7  * The dbus-cxx library is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU General Public License *
9  * version 3 as published by the Free Software Foundation. *
10  * *
11  * The dbus-cxx library is distributed in the hope that it will be *
12  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this software. If not see <http://www.gnu.org/licenses/>. *
18  ***************************************************************************/
19 #include <exception>
20 
21 #include <dbus-cxx/pointer.h>
22 
23 #include <dbus/dbus.h>
24 
25 #include <string>
26 
27 #ifndef DBUSCXX_ERROR_H
28 #define DBUSCXX_ERROR_H
29 
30 namespace DBus
31 {
32 
33  class Message;
34 
51  class Error : public std::exception
52  {
53 
54  protected:
55 
56  Error();
57 
58  Error( DBusError* cobj );
59 
60  Error( const char* name, const char* message=NULL );
61 
62  Error( Message& );
63 
64  public:
65  typedef DBusCxxPointer<Error> pointer;
66 
67  static pointer create();
68 
69  static pointer create( DBusError* cobj );
70 
71  static pointer create( const char* name, const char* message );
72 
73  static pointer create( Message& );
74 
75  ~Error() throw();
76 
77  const char* what() const throw();
78 
79  const char* name() const;
80 
81  const char* message() const;
82 
84  void set( const char* name, const char* message );
85 
86  bool is_set() const;
87 
88  operator bool() const;
89 
90 // Error& operator=( Error& other );
91 
92  DBusError* cobj();
93 
94  protected:
95  DBusError m_cobj;
96 
97  };
98 
99 #define DBUSCXX_ERROR( CPPTYPE, DBUS_ERROR_CODE ) \
100  class CPPTYPE : public Error { \
101  protected: \
102  CPPTYPE( const char* message = NULL ) \
103  : Error( DBUS_ERROR_CODE, message ) {} \
104  public: \
105  typedef DBusCxxPointer<CPPTYPE> pointer; \
106  static pointer create( const char* message = NULL ) { \
107  return pointer( new CPPTYPE(message) ); \
108  } \
109  }
110 
116  DBUSCXX_ERROR( ErrorFailed, DBUS_ERROR_FAILED );
117 
123  DBUSCXX_ERROR( ErrorNoMemory, DBUS_ERROR_NO_MEMORY );
124 
130  DBUSCXX_ERROR( ErrorServiceUnknown, DBUS_ERROR_SERVICE_UNKNOWN );
131 
137  DBUSCXX_ERROR( ErrorNameHasNoOwner, DBUS_ERROR_NAME_HAS_NO_OWNER );
138 
144  DBUSCXX_ERROR( ErrorNoReply, DBUS_ERROR_NO_REPLY );
145 
151  DBUSCXX_ERROR( ErrorIOError, DBUS_ERROR_IO_ERROR );
152 
158  DBUSCXX_ERROR( ErrorBadAddress, DBUS_ERROR_BAD_ADDRESS );
159 
165  DBUSCXX_ERROR( ErrorNotSupported, DBUS_ERROR_NOT_SUPPORTED );
166 
172  DBUSCXX_ERROR( ErrorLimitsExceeded, DBUS_ERROR_LIMITS_EXCEEDED );
173 
179  DBUSCXX_ERROR( ErrorAccessDenied, DBUS_ERROR_ACCESS_DENIED );
180 
186  DBUSCXX_ERROR( ErrorAuthFailed, DBUS_ERROR_AUTH_FAILED );
187 
193  DBUSCXX_ERROR( ErrorNoServer, DBUS_ERROR_NO_SERVER );
194 
200  DBUSCXX_ERROR( ErrorTimeout, DBUS_ERROR_TIMEOUT );
201 
207  DBUSCXX_ERROR( ErrorNoNetwork, DBUS_ERROR_NO_NETWORK );
208 
214  DBUSCXX_ERROR( ErrorAddressInUse, DBUS_ERROR_ADDRESS_IN_USE );
215 
221  DBUSCXX_ERROR( ErrorDisconnected, DBUS_ERROR_DISCONNECTED );
222 
228  DBUSCXX_ERROR( ErrorInvalidArgs, DBUS_ERROR_INVALID_ARGS );
229 
235  DBUSCXX_ERROR( ErrorFileNotFound, DBUS_ERROR_FILE_NOT_FOUND );
236 
242  DBUSCXX_ERROR( ErrorFileExists, DBUS_ERROR_FILE_EXISTS );
243 
249  DBUSCXX_ERROR( ErrorUnknownMethod, DBUS_ERROR_UNKNOWN_METHOD );
250 
256  DBUSCXX_ERROR( ErrorTimedOut, DBUS_ERROR_TIMED_OUT );
257 
263  DBUSCXX_ERROR( ErrorMatchRuleNotFound, DBUS_ERROR_MATCH_RULE_NOT_FOUND );
264 
270  DBUSCXX_ERROR( ErrorMatchRuleInvalid, DBUS_ERROR_MATCH_RULE_INVALID );
271 
277  DBUSCXX_ERROR( ErrorSpawnExecFailed, DBUS_ERROR_SPAWN_EXEC_FAILED );
278 
284  DBUSCXX_ERROR( ErrorSpawnForkFailed, DBUS_ERROR_SPAWN_FORK_FAILED );
285 
291  DBUSCXX_ERROR( ErrorSpawnChildExited, DBUS_ERROR_SPAWN_CHILD_EXITED );
292 
298  DBUSCXX_ERROR( ErrorSpawnChildSignaled, DBUS_ERROR_SPAWN_CHILD_SIGNALED );
299 
305  DBUSCXX_ERROR( ErrorSpawnFailed, DBUS_ERROR_SPAWN_FAILED );
306 
312  DBUSCXX_ERROR( ErrorUnixProcessIdUnknown, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN );
313 
319  DBUSCXX_ERROR( ErrorInvalidSignature, DBUS_ERROR_INVALID_SIGNATURE );
320 
326  DBUSCXX_ERROR( ErrorInvalidFileContent, DBUS_ERROR_INVALID_FILE_CONTENT );
327 
333  DBUSCXX_ERROR( ErrorSELinuxSecurityContextUnknown, DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN );
334 
340  DBUSCXX_ERROR( ErrorInvalidCObject, "Invalid C Object" );
341 
347  DBUSCXX_ERROR( ErrorInvalidTypecast, "Invalid Typecast" );
348 
354  DBUSCXX_ERROR( ErrorInvalidConnection, "DBus connection is invalid" );
355 
361  DBUSCXX_ERROR( ErrorInvalidMessageType, "DBus message type does not match the C++ Message object type" );
362 
368  DBUSCXX_ERROR( ErrorNoConnection, "No connection specified and operation requires a DBus connection" );
369 
375  DBUSCXX_ERROR( ErrorDeadlock, "Locking a mutex a dbus-cxx thread already owns" );
376 
382  DBUSCXX_ERROR( ErrorNotOwner, "Unlocking a mutex a dbus-cxx thread doesn't own" );
383 
389  DBUSCXX_ERROR( ErrorNotInitialized, "DBus::init(bool threadsafe=true) not called" );
390 
396  DBUSCXX_ERROR( ErrorInvalidAdaptee, "DBus adapter method called, but adaptee is invalid" );
397 
402  DBUSCXX_ERROR( ErrorDispatcherInitFailed, "DBus::Dispatcher initialization failed" );
403 
404 
405 }
406 
407 #endif
DBusCxxPointer< Error > pointer
Definition: error.h:65
Definition: accumulators.h:24
const char * what() const
Definition: error.cpp:103
~Error()
Definition: error.cpp:67
DBusError m_cobj
Definition: error.h:95
DBUSCXX_ERROR(ErrorFailed, DBUS_ERROR_FAILED)
void set(const char *name, const char *message)
parameters MUST be static strings
Definition: error.cpp:98
const char * name() const
Definition: error.cpp:72
This class represents a basic DBus message and also serves as a base class for the specialized messag...
Definition: message.h:56
DBusError * cobj()
Definition: error.cpp:108
const char * message() const
Definition: error.cpp:77
Base class of a hierarchy of error objects thrown when exceptional conditions occur.
Definition: error.h:51
static pointer create()
Definition: error.cpp:47
Error()
Definition: error.cpp:25
bool is_set() const
Definition: error.cpp:82

Generated on Sun Mar 19 2017 14:54:27 for dbus-cxx by doxygen 1.8.8