Free memory with dbus_free instead of free. Account for NULL signatures.
[dbus-cxx-async.git] / src / error.cpp
blobeadee962b76547bdea5767111e15416886634c7d
1 /*
3 * D-Bus++ - C++ bindings for D-Bus
5 * Copyright (C) 2005-2009 Paolo Durante <shackan@gmail.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
28 #include <dbus-c++/message.h>
29 #include <dbus-c++/error.h>
31 #include <dbus/dbus.h>
33 #include "message_p.h"
34 #include "internalerror.h"
36 using namespace DBus;
41 Error::Error()
42 : _int(new InternalError)
45 Error::Error(InternalError &i)
46 : _int(new InternalError(i))
49 Error::Error(const char *name, const char *description)
50 : _int(new InternalError)
52 set(name, description);
55 Error::Error(Message &m)
56 : _int(new InternalError)
58 dbus_set_error_from_message(&(_int->error), m._pvt->msg);
61 Error::~Error() throw()
65 const char *Error::name() const
67 return _int->error.name;
70 const char *Error::description() const
72 return _int->error.message;
75 bool Error::is_set() const
77 return *(_int);
80 void Error::set(const ErrorMessage &error)
82 dbus_set_error_from_message(&(_int->error), error._pvt->msg);
85 void Error::set(const char *name, const char *description)
87 dbus_set_error_const(&(_int->error), name, description);
90 const char *Error::what() const throw()
92 return _int->error.message;