summaryrefslogtreecommitdiff
path: root/gio/src/dbuserrorutils.hg
blob: 82a11cbf6e8d2118624b7cb29255e32b2e6de81c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Copyright (C) 2010 The giomm Development Team
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(giommconfig.h)

_DEFS(giomm,gio)

namespace Glib
{

class Error;

}

namespace Gio
{

namespace DBus
{

namespace ErrorUtils
{

/** Checks if @a error represents an error received via D-Bus from a remote
 * peer.  If so, use get_remote_error() to get the name of the error.
 *
 * @param error A Glib::Error.
 * @return <tt>true</tt> if error represents an error from a remote peer,
 * <tt>false</tt> otherwise.
 * @newin{2,28}
 * @ingroup DBus
 */
GIOMM_API
bool is_remote_error(const Glib::Error& error);

/** Gets the D-Bus error name used for @a error, if any.
 *
 * This function is guaranteed to return a D-Bus error name for all
 * Glib::Error instances returned from functions handling remote method calls
 * (e.g. Gio::DBus::Connection::call_finish()) unless strip_remote_error() has
 * been used on @a error.
 *
 * @param error A Glib::Error.
 * @return An allocated string or <tt>0</tt> if the D-Bus error name could not
 * be found.
 * @newin{2,28}
 * @ingroup DBus
 */
GIOMM_API
Glib::ustring get_remote_error(const Glib::Error& error);

/** Looks for extra information in the error message used to recover the D-Bus
 * error name and strips it if found. If stripped, the message field in @a
 * error will correspond exactly to what was received on the wire.
 *
 * This is typically used when presenting errors to the end user.
 *
 * @param error A Glib::Error.
 * @return <tt>true</tt> if information was stripped, <tt>false</tt>
 * otherwise.
 * @newin{2,28}
 * @ingroup DBus
 */
GIOMM_API
bool strip_remote_error(Glib::Error& error);

} // namespace ErrorUtils

} // namespace DBus

} // namespace Gio