dbus-cplusplus/include/dbus-c++/error.h
2006-09-05 13:36:22 +00:00

231 lines
4.8 KiB
C++

/*
*
* D-Bus++ - C++ bindings for DBus
*
* Copyright (C) 2005-2006 Paolo Durante <shackan@gmail.com>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __DBUSXX_ERROR_H
#define __DBUSXX_ERROR_H
#include "util.h"
#include <exception>
namespace DBus {
class Message;
class InternalError;
class Error : public std::exception
{
public:
Error();
Error( InternalError& );
Error( const char* name, const char* message );
Error( Message& );
~Error() throw()
{}
const char* what() const throw();
const char* name();
const char* message();
void set( const char* name, const char* message );
// parameters MUST be static strings
bool is_set();
operator bool()
{
return is_set();
}
private:
RefPtrI<InternalError> _int;
};
struct ErrorFailed : public Error
{
ErrorFailed( const char* message )
: Error("org.freedesktop.DBus.Error.Failed", message)
{}
};
struct ErrorNoMemory : public Error
{
ErrorNoMemory( const char* message )
: Error("org.freedesktop.DBus.Error.NoMemory", message)
{}
};
struct ErrorServiceUnknown : public Error
{
ErrorServiceUnknown( const char* message )
: Error("org.freedesktop.DBus.Error.ServiceUnknown", message)
{}
};
struct ErrorNameHasNoOwner : public Error
{
ErrorNameHasNoOwner( const char* message )
: Error("org.freedesktop.DBus.Error.NameHasNoOwner", message)
{}
};
struct ErrorNoReply : public Error
{
ErrorNoReply( const char* message )
: Error("org.freedesktop.DBus.Error.NoReply", message)
{}
};
struct ErrorIOError : public Error
{
ErrorIOError( const char* message )
: Error("org.freedesktop.DBus.Error.IOError", message)
{}
};
struct ErrorBadAddress : public Error
{
ErrorBadAddress( const char* message )
: Error("org.freedesktop.DBus.Error.BadAddress", message)
{}
};
struct ErrorNotSupported : public Error
{
ErrorNotSupported( const char* message )
: Error("org.freedesktop.DBus.Error.NotSupported", message)
{}
};
struct ErrorLimitsExceeded : public Error
{
ErrorLimitsExceeded( const char* message )
: Error("org.freedesktop.DBus.Error.LimitsExceeded", message)
{}
};
struct ErrorAccessDenied : public Error
{
ErrorAccessDenied( const char* message )
: Error("org.freedesktop.DBus.Error.AccessDenied", message)
{}
};
struct ErrorAuthFailed : public Error
{
ErrorAuthFailed( const char* message )
: Error("org.freedesktop.DBus.Error.AuthFailed", message)
{}
};
struct ErrorNoServer : public Error
{
ErrorNoServer( const char* message )
: Error("org.freedesktop.DBus.Error.NoServer", message)
{}
};
struct ErrorTimeout : public Error
{
ErrorTimeout( const char* message )
: Error("org.freedesktop.DBus.Error.Timeout", message)
{}
};
struct ErrorNoNetwork : public Error
{
ErrorNoNetwork( const char* message )
: Error("org.freedesktop.DBus.Error.NoNetwork", message)
{}
};
struct ErrorAddressInUse : public Error
{
ErrorAddressInUse( const char* message )
: Error("org.freedesktop.DBus.Error.AddressInUse", message)
{}
};
struct ErrorDisconnected : public Error
{
ErrorDisconnected( const char* message )
: Error("org.freedesktop.DBus.Error.Disconnected", message)
{}
};
struct ErrorInvalidArgs : public Error
{
ErrorInvalidArgs( const char* message )
: Error("org.freedesktop.DBus.Error.InvalidArgs", message)
{}
};
struct ErrorFileNotFound : public Error
{
ErrorFileNotFound( const char* message )
: Error("org.freedesktop.DBus.Error.FileNotFound", message)
{}
};
struct ErrorUnknownMethod : public Error
{
ErrorUnknownMethod( const char* message )
: Error("org.freedesktop.DBus.Error.UnknownMethod", message)
{}
};
struct ErrorTimedOut : public Error
{
ErrorTimedOut( const char* message )
: Error("org.freedesktop.DBus.Error.TimedOut", message)
{}
};
struct ErrorMatchRuleNotFound : public Error
{
ErrorMatchRuleNotFound( const char* message )
: Error("org.freedesktop.DBus.Error.MatchRuleNotFound", message)
{}
};
struct ErrorMatchRuleInvalid : public Error
{
ErrorMatchRuleInvalid( const char* message )
: Error("org.freedesktop.DBus.Error.MatchRuleInvalid", message)
{}
};
/* TODO: add the remaining error codes from dbus-protocol.h */
} /* namespace DBus */
#endif//__DBUSXX_ERROR_H