error.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later OR BSD-3-Clause
2 /***************************************************************************
3  * Copyright (C) 2007,2008,2009,2010 by Rick L. Vinyard, Jr. *
4  * rvinyard@cs.nmsu.edu *
5  * *
6  * This file is part of the dbus-cxx library. *
7  ***************************************************************************/
8 #include <exception>
9 #include <string>
10 #include <dbus-cxx/dbus-error.h>
11 
12 #ifndef DBUSCXX_ERROR_H
13 #define DBUSCXX_ERROR_H
14 
15 namespace DBus {
16 
17 class Message;
18 
35 class Error : public std::exception {
36 public:
37  Error();
38 
39  Error( const char* name, const char* message = nullptr );
40 
41  Error( const char* name, std::string message );
42 
43  Error( std::string name, std::string message );
44 
45  ~Error() noexcept;
46 
47  const char* what() const noexcept;
48 
49  std::string name() const;
50 
51  std::string message() const;
52 
53 protected:
54  std::string m_name;
55  std::string m_message;
56 
57 };
58 
59 #define DBUSCXX_ERROR( CPPTYPE, DBUS_ERROR_CODE ) \
60  class CPPTYPE : public Error { \
61  public: \
62  CPPTYPE( const char* message = nullptr ) \
63  : Error( DBUS_ERROR_CODE, message ) {} \
64  CPPTYPE( std::string message ) \
65  : Error( DBUS_ERROR_CODE, message ) {} \
66  }
67 
74 
81 
88 
95 
102 
109 
116 
123 
130 
137 
144 
151 
158 
165 
172 
179 
186 
193 
200 
207 
213 
219 
225 
231 
238 
245 
252 
259 
266 
273 
280 
287 
294 
301 
308 
315 
321 DBUSCXX_ERROR( ErrorInvalidCObject, "Invalid C Object" );
322 
328 DBUSCXX_ERROR( ErrorInvalidTypecast, "Invalid Typecast" );
329 
335 DBUSCXX_ERROR( ErrorInvalidConnection, "DBus connection is invalid" );
336 
342 DBUSCXX_ERROR( ErrorInvalidMessageType, "DBus message type does not match the C++ Message object type" );
343 
349 DBUSCXX_ERROR( ErrorNoConnection, "No connection specified and operation requires a DBus connection" );
350 
356 DBUSCXX_ERROR( ErrorDeadlock, "Locking a mutex a dbus-cxx thread already owns" );
357 
363 DBUSCXX_ERROR( ErrorNotOwner, "Unlocking a mutex a dbus-cxx thread doesn't own" );
364 
370 DBUSCXX_ERROR( ErrorNotInitialized, "DBus::init(bool threadsafe=true) not called" );
371 
377 DBUSCXX_ERROR( ErrorInvalidAdaptee, "DBus adapter method called, but adaptee is invalid" );
378 
383 DBUSCXX_ERROR( ErrorDispatcherInitFailed, "DBus::Dispatcher initialization failed" );
384 
389 DBUSCXX_ERROR( ErrorInvalidSharedPtr, "shared_ptr was invalid" );
390 
395 DBUSCXX_ERROR( ErrorPollFailed, "poll() syscall failed" );
396 
401 DBUSCXX_ERROR( ErrorInvalidReturn, "dbuscxx.Error.InvalidReturnValue" );
402 
406 DBUSCXX_ERROR( ErrorUnexpectedResponse, "dbuscxx.Error.UnexpectedResponse" );
407 
409 public:
410  ErrorIncorrectDispatchThread( const char* message = nullptr )
411  : Error( nullptr, message ) {}
412 };
413 
414 class ErrorRemoteException : public Error {
415 public:
416  ErrorRemoteException( const char* message = nullptr )
417  : Error( nullptr, message ) {}
418 };
419 
420 class ErrorUnknown : public Error {
421 public:
422  ErrorUnknown( const char* message = nullptr )
423  : Error( nullptr, message ) {}
424 };
425 
426 class ErrorBadVariantCast : public Error {
427 public:
428  ErrorBadVariantCast( const char* message = nullptr )
429  : Error( nullptr, message ) {}
430 };
431 
435 class ErrorUnableToParse : public Error {
436 public:
437  ErrorUnableToParse( const char* message = nullptr )
438  : Error( nullptr, message ) {}
439 };
440 
444 class ErrorInvalidMessage : public Error {
445 public:
446  ErrorInvalidMessage( const char* message = nullptr )
447  : Error( nullptr, message ) {}
448 };
449 
451 public:
452  ErrorMessageNestedTooDeep( const char* message = nullptr )
453  : Error( nullptr, message ) {}
454 };
455 
456 }
457 
458 #endif
Definition: error.h:426
ErrorBadVariantCast(const char *message=nullptr)
Definition: error.h:428
Definition: error.h:408
ErrorIncorrectDispatchThread(const char *message=nullptr)
Definition: error.h:410
An invalid message was tried to be parsed.
Definition: error.h:444
ErrorInvalidMessage(const char *message=nullptr)
Definition: error.h:446
Definition: error.h:450
ErrorMessageNestedTooDeep(const char *message=nullptr)
Definition: error.h:452
Definition: error.h:414
ErrorRemoteException(const char *message=nullptr)
Definition: error.h:416
We were unable to parse(something is unimplemented?)
Definition: error.h:435
ErrorUnableToParse(const char *message=nullptr)
Definition: error.h:437
Definition: error.h:420
ErrorUnknown(const char *message=nullptr)
Definition: error.h:422
Base class of a hierarchy of error objects thrown when exceptional conditions occur.
Definition: error.h:35
std::string name() const
Definition: error.cpp:39
std::string m_name
Definition: error.h:54
Error()
Definition: error.cpp:13
const char * what() const noexcept
Definition: error.cpp:47
std::string message() const
Definition: error.cpp:43
std::string m_message
Definition: error.h:55
~Error() noexcept
Definition: error.cpp:36
#define DBUSCXX_ERROR_FAILED
A generic error; "something went wrong" - see the error message for more.
Definition: dbus-error.h:17
#define DBUSCXX_ERROR_NOT_SUPPORTED
Requested operation isn't supported (like ENOSYS on UNIX).
Definition: dbus-error.h:31
#define DBUSCXX_ERROR_FILE_EXISTS
Existing file and the operation you're using does not silently overwrite.
Definition: dbus-error.h:57
#define DBUSCXX_ERROR_SERVICE_UNKNOWN
The bus doesn't know how to launch a service to supply the bus name you wanted.
Definition: dbus-error.h:21
#define DBUSCXX_ERROR_NO_SERVER
Unable to connect to server (probably caused by ECONNREFUSED on a socket).
Definition: dbus-error.h:39
#define DBUSCXX_ERROR_FILE_NOT_FOUND
Missing file.
Definition: dbus-error.h:55
#define DBUSCXX_ERROR_BAD_ADDRESS
A D-Bus bus address was malformed.
Definition: dbus-error.h:29
#define DBUSCXX_ERROR_IO_ERROR
Something went wrong reading or writing to a socket, for example.
Definition: dbus-error.h:27
#define DBUSCXX_ERROR_DISCONNECTED
The connection is disconnected and you're trying to use it.
Definition: dbus-error.h:51
#define DBUSCXX_ERROR_UNKNOWN_INTERFACE
Interface you invoked a method on isn't known by the object.
Definition: dbus-error.h:63
#define DBUSCXX_ERROR_TIMED_OUT
Certain timeout errors, e.g.
Definition: dbus-error.h:72
#define DBUSCXX_ERROR_NO_NETWORK
No network access (probably ENETUNREACH on a socket).
Definition: dbus-error.h:47
#define DBUSCXX_ERROR_PROPERTY_READ_ONLY
Property you tried to set is read-only.
Definition: dbus-error.h:67
#define DBUSCXX_ERROR_INVALID_ARGS
Invalid arguments passed to a method call.
Definition: dbus-error.h:53
#define DBUSCXX_ERROR_SPAWN_FAILED
While starting a new process, something went wrong.
Definition: dbus-error.h:86
#define DBUSCXX_ERROR_ADDRESS_IN_USE
Can't bind a socket since its address is in use (i.e.
Definition: dbus-error.h:49
#define DBUSCXX_ERROR_MATCH_RULE_INVALID
The match rule isn't syntactically valid.
Definition: dbus-error.h:76
#define DBUSCXX_ERROR_TIMEOUT
Certain timeout errors, possibly ETIMEDOUT on a socket.
Definition: dbus-error.h:45
#define DBUSCXX_ERROR_NAME_HAS_NO_OWNER
The bus name you referenced doesn't exist (i.e.
Definition: dbus-error.h:23
#define DBUSCXX_ERROR_INVALID_FILE_CONTENT
A file contains invalid syntax or is otherwise broken.
Definition: dbus-error.h:106
#define DBUSCXX_ERROR_UNIX_PROCESS_ID_UNKNOWN
Tried to get a UNIX process ID and it wasn't available.
Definition: dbus-error.h:102
#define DBUSCXX_ERROR_SPAWN_CHILD_EXITED
While starting a new process, the child exited with a status code.
Definition: dbus-error.h:82
#define DBUSCXX_ERROR_LIMITS_EXCEEDED
Some limited resource is exhausted.
Definition: dbus-error.h:33
#define DBUSCXX_ERROR_MATCH_RULE_NOT_FOUND
Tried to remove or modify a match rule that didn't exist.
Definition: dbus-error.h:74
#define DBUSCXX_ERROR_UNKNOWN_PROPERTY
Property you tried to access isn't known by the object.
Definition: dbus-error.h:65
#define DBUSCXX_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
Definition: dbus-error.h:19
#define DBUSCXX_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN
Asked for SELinux security context and it wasn't available.
Definition: dbus-error.h:108
#define DBUSCXX_ERROR_SPAWN_EXEC_FAILED
While starting a new process, the exec() call failed.
Definition: dbus-error.h:78
#define DBUSCXX_ERROR_NO_REPLY
No reply to a message expecting one, usually means a timeout occurred.
Definition: dbus-error.h:25
#define DBUSCXX_ERROR_INVALID_SIGNATURE
A type signature is not valid.
Definition: dbus-error.h:104
#define DBUSCXX_ERROR_UNKNOWN_METHOD
Method name you invoked isn't known by the object you invoked it on.
Definition: dbus-error.h:59
#define DBUSCXX_ERROR_UNKNOWN_OBJECT
Object you invoked a method on isn't known.
Definition: dbus-error.h:61
#define DBUSCXX_ERROR_ACCESS_DENIED
Security restrictions don't allow doing what you're trying to do.
Definition: dbus-error.h:35
#define DBUSCXX_ERROR_SPAWN_FORK_FAILED
While starting a new process, the fork() call failed.
Definition: dbus-error.h:80
#define DBUSCXX_ERROR_AUTH_FAILED
Authentication didn't work.
Definition: dbus-error.h:37
#define DBUSCXX_ERROR_SPAWN_CHILD_SIGNALED
While starting a new process, the child exited on a signal.
Definition: dbus-error.h:84
Global DBus namespace, where everything happens.
Definition: callmessage.cpp:18
DBUSCXX_ERROR(ErrorFailed, DBUSCXX_ERROR_FAILED)