error.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *  D-Bus++ - C++ bindings for D-Bus
00004  *
00005  *  Copyright (C) 2005-2007  Paolo Durante <shackan@gmail.com>
00006  *
00007  *
00008  *  This library is free software; you can redistribute it and/or
00009  *  modify it under the terms of the GNU Lesser General Public
00010  *  License as published by the Free Software Foundation; either
00011  *  version 2.1 of the License, or (at your option) any later version.
00012  *
00013  *  This library is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  *  Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public
00019  *  License along with this library; if not, write to the Free Software
00020  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027 
00028 #include <dbus-c++/message.h>
00029 #include <dbus-c++/error.h>
00030 
00031 #include <dbus/dbus.h>
00032 
00033 #include "message_p.h"
00034 #include "internalerror.h"
00035 
00036 using namespace DBus;
00037 
00038 /*
00039 */
00040 
00041 Error::Error()
00042   : _int(new InternalError)
00043 {}
00044 
00045 Error::Error(InternalError &i)
00046   : _int(new InternalError(i))
00047 {}
00048 
00049 Error::Error(const char *name, const char *message)
00050   : _int(new InternalError)
00051 {
00052   set(name, message);
00053 }
00054 
00055 Error::Error(Message &m)
00056   : _int(new InternalError)
00057 {
00058   dbus_set_error_from_message(&(_int->error), m._pvt->msg);
00059 }
00060 
00061 Error::~Error() throw()
00062 {
00063 }
00064 
00065 const char *Error::name() const
00066 {
00067   return _int->error.name;
00068 }
00069 
00070 const char *Error::message() const
00071 {
00072   return _int->error.message;
00073 }
00074 
00075 bool Error::is_set() const
00076 {
00077   return *(_int);
00078 }
00079 
00080 void Error::set(const char *name, const char *message)
00081 {
00082   dbus_set_error_const(&(_int->error), name, message);
00083 }
00084 
00085 const char *Error::what() const throw()
00086 {
00087   return _int->error.message;
00088 }
00089