]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_bus_message_new_method_error.xml
test: mark plymouth as optional dependency
[thirdparty/systemd.git] / man / sd_bus_message_new_method_error.xml
CommitLineData
e50f4718
ZJS
1<?xml version='1.0'?>
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5<!--
6 SPDX-License-Identifier: LGPL-2.1+
7-->
8
9<refentry id="sd_bus_message_new_method_error"
10 xmlns:xi="http://www.w3.org/2001/XInclude">
11
12 <refentryinfo>
13 <title>sd_bus_message_new_method_error</title>
14 <productname>systemd</productname>
15 </refentryinfo>
16
17 <refmeta>
18 <refentrytitle>sd_bus_message_new_method_error</refentrytitle>
19 <manvolnum>3</manvolnum>
20 </refmeta>
21
22 <refnamediv>
23 <refname>sd_bus_message_new_method_error</refname>
24 <refname>sd_bus_message_new_method_errorf</refname>
25 <refname>sd_bus_message_new_method_errno</refname>
26 <refname>sd_bus_message_new_method_errnof</refname>
27
28 <refpurpose>Create a an error reply for a method call</refpurpose>
29 </refnamediv>
30
31 <refsynopsisdiv>
32 <funcsynopsis>
33 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
34
35 <funcprototype>
36 <funcdef>int sd_bus_message_new_method_error</funcdef>
37 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
38 <paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
39 <paramdef>const sd_bus_error *<parameter>e</parameter></paramdef>
40 </funcprototype>
41
42 <funcprototype>
43 <funcdef>int sd_bus_message_new_method_errorf</funcdef>
44 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
45 <paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
46 <paramdef>const char *<parameter>name</parameter></paramdef>
47 <paramdef>const char *<parameter>format</parameter></paramdef>
48 <paramdef>…</paramdef>
49 </funcprototype>
50
51 <funcprototype>
52 <funcdef>int sd_bus_message_new_method_errno</funcdef>
53 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
54 <paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
55 <paramdef>int <parameter>error</parameter></paramdef>
56 <paramdef>const sd_bus_error *<parameter>p</parameter></paramdef>
57 </funcprototype>
58
59 <funcprototype>
60 <funcdef>int sd_bus_message_new_method_errnof</funcdef>
61 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
62 <paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
63 <paramdef>int <parameter>error</parameter></paramdef>
64 <paramdef>const char *<parameter>format</parameter></paramdef>
65 <paramdef>…</paramdef>
66 </funcprototype>
67 </funcsynopsis>
68 </refsynopsisdiv>
69
70 <refsect1>
71 <title>Description</title>
72
73 <para>The <function>sd_bus_message_new_method_error()</function> function creates
74 a new bus message object that is an error reply to the
75 <parameter>call</parameter> message, and returns it in the
76 <parameter>m</parameter> output parameter. The error information from error
77 <parameter>e</parameter> is appended: the <parameter>name</parameter> field of
78 <parameter>e</parameter> is used as the error identifier in the reply header (for
79 example an error name such as
80 <literal>org.freedesktop.DBus.Error.NotSupported</literal> or the equivalent
81 symbolic <constant>SD_BUS_ERROR_NOT_SUPPORTED</constant>), and the
82 <parameter>message</parameter> field is set as the human readable error message
83 string if present. The error <parameter>e</parameter> must have the
84 <parameter>name</parameter> field set, see
85 <citerefentry><refentrytitle>sd_bus_error_is_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
86 </para>
87
88 <para>The <function>sd_bus_message_new_method_errorf()</function> function
89 creates an error reply similarly to
90 <function>sd_bus_message_new_method_error()</function>, but instead of a ready
91 error structure, it takes an error identifier string <parameter>name</parameter>,
92 plus a <citerefentry
93 project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
94 format string <parameter>format</parameter> and corresponding arguments. An error
95 reply is sent with the error identifier <parameter>name</parameter> and the
96 formatted string as the message. <parameter>name</parameter> and
97 <parameter>format</parameter> must not be <constant>NULL</constant>.
98 </para>
99
100 <para>The <function>sd_bus_message_new_method_errno()</function> function creates
101 an error reply similarly to
102 <function>sd_bus_message_new_method_error()</function>, but in addition to the
103 error structure <parameter>p</parameter>, it takes an
104 <citerefentry><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
105 error value in parameter <parameter>error</parameter>. If the error
106 <parameter>p</parameter> is set (see
107 <citerefentry><refentrytitle>sd_bus_error_is_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>),
108 it is used in the reply. Otherwise, <parameter>error</parameter> is translated to
109 an error identifier and used to create a new error structure using
110 <citerefentry><refentrytitle>sd_bus_error_set_errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
111 and that is used in the reply. (If <parameter>error</parameter> is zero, no error
112 is actually set, and an error reply with no information is created.)</para>
113
114 <para>The <function>sd_bus_message_new_method_errnof()</function> function
115 creates an error reply similarly to
116 <function>sd_bus_message_new_method_error()</function>. It takes an
117 <citerefentry><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
118 error value in parameter <parameter>error</parameter>, plus a <citerefentry
119 project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
120 format string <parameter>format</parameter> and corresponding arguments.
121 <literal>%m</literal> may be used in the format string to refer to the error
122 string corresponding to the specified errno code. The error message is initalized
123 using the error identifier generated from <constant>error</constant> and the
124 formatted string. (If <parameter>error</parameter> is zero, no error is actually
125 set, and an error reply with no information is created.)</para>
126 </refsect1>
127
128 <refsect1>
129 <title>Return Value</title>
130
131 <para>These functions return 0 if the error reply was successfully created, and a
132 negative errno-style error code otherwise.</para>
133 </refsect1>
134
135 <refsect1 id='errors'>
136 <title>Errors</title>
137
138 <para>Returned errors may indicate the following problems:</para>
139
140 <variablelist>
141 <varlistentry>
142 <term><constant>-EINVAL</constant></term>
143
144 <listitem><para>The call message <parameter>call</parameter> or the output
145 parameter <parameter>m</parameter> are <constant>NULL</constant>.</para>
146
147 <para>Message <parameter>call</parameter> is not a method call
148 message.</para>
149
150 <para>The error <parameter>error</parameter> parameter to
151 <function>sd_bus_message_new_method_error</function> is not set, see
152 <citerefentry><refentrytitle>sd_bus_error_is_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
153 </para>
154 </listitem>
155 </varlistentry>
156
157 <varlistentry>
158 <term><constant>-EPERM</constant></term>
159
160 <listitem><para>Message <parameter>call</parameter> has been sealed.
161 </para></listitem>
162 </varlistentry>
163
164 <varlistentry>
165 <term><constant>-ENOTCONN</constant></term>
166
167 <listitem><para>The bus to which message <parameter>call</parameter> is
168 attached is not connected.</para></listitem>
169 </varlistentry>
170
171 <varlistentry>
172 <term><constant>-ENOMEM</constant></term>
173
174 <listitem><para>Memory allocation failed.</para></listitem>
175 </varlistentry>
176 </variablelist>
177 </refsect1>
178
179 <xi:include href="libsystemd-pkgconfig.xml" />
180
181 <refsect1>
182 <title>See Also</title>
183
184 <para>
185 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
186 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>
187 </para>
188 </refsect1>
189
190</refentry>