2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_bus_reply_method_error"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
10 <title>sd_bus_reply_method_error</title>
11 <productname>systemd</productname>
15 <refentrytitle>sd_bus_reply_method_error</refentrytitle>
16 <manvolnum>3</manvolnum>
20 <refname>sd_bus_reply_method_error</refname>
21 <refname>sd_bus_reply_method_errorf</refname>
22 <refname>sd_bus_reply_method_errorfv</refname>
23 <refname>sd_bus_reply_method_errno</refname>
24 <refname>sd_bus_reply_method_errnof</refname>
25 <refname>sd_bus_reply_method_errnofv</refname>
27 <refpurpose>Reply with an error to a D-Bus method call</refpurpose>
32 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
35 <funcdef>int sd_bus_reply_method_error</funcdef>
36 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
37 <paramdef>const sd_bus_error *<parameter>e</parameter></paramdef>
41 <funcdef>int sd_bus_reply_method_errorf</funcdef>
42 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
43 <paramdef>const char *<parameter>name</parameter></paramdef>
44 <paramdef>const char *<parameter>format</parameter></paramdef>
45 <paramdef>...</paramdef>
49 <funcdef>int sd_bus_reply_method_errorfv</funcdef>
50 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
51 <paramdef>const char *<parameter>name</parameter></paramdef>
52 <paramdef>const char *<parameter>format</parameter></paramdef>
53 <paramdef>va_list <parameter>ap</parameter></paramdef>
57 <funcdef>int sd_bus_reply_method_errno</funcdef>
58 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
59 <paramdef>int <parameter>error</parameter></paramdef>
60 <paramdef>const sd_bus_error *<parameter>p</parameter></paramdef>
64 <funcdef>int sd_bus_reply_method_errnof</funcdef>
65 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
66 <paramdef>int <parameter>error</parameter></paramdef>
67 <paramdef>const char *<parameter>format</parameter></paramdef>
68 <paramdef>...</paramdef>
72 <funcdef>int sd_bus_reply_method_errnofv</funcdef>
73 <paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
74 <paramdef>int <parameter>error</parameter></paramdef>
75 <paramdef>const char *<parameter>format</parameter></paramdef>
76 <paramdef>va_list <parameter>ap</parameter></paramdef>
82 <title>Description</title>
84 <para>The <function>sd_bus_reply_method_error()</function> function sends an error reply to the
85 <parameter>call</parameter> message. The error structure <parameter>e</parameter> specifies the
86 error to send, and is used as described in
87 <citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
88 If no reply is expected to <parameter>call</parameter>, this function succeeds without sending a
91 <para>The <function>sd_bus_reply_method_errorf()</function> is to
92 <function>sd_bus_reply_method_error()</function> what
93 <function>sd_bus_message_new_method_errorf()</function> is to
94 <function>sd_bus_message_new_method_error()</function>.</para>
96 <para>The <function>sd_bus_reply_method_errno()</function> is to
97 <function>sd_bus_reply_method_error()</function> what
98 <function>sd_bus_message_new_method_errno()</function> is to
99 <function>sd_bus_message_new_method_error()</function>.</para>
101 <para>The <function>sd_bus_reply_method_errnof()</function> is to
102 <function>sd_bus_reply_method_error()</function> what
103 <function>sd_bus_message_new_method_errnof()</function> is to
104 <function>sd_bus_message_new_method_error()</function>.</para>
108 <title>Return Value</title>
110 <para>This function returns a non-negative integer if the error reply was successfully sent or
111 if <parameter>call</parameter> does not expect a reply. On failure, it returns a negative
112 errno-style error code.</para>
115 <title>Errors</title>
117 <para>Returned errors may indicate the following problems:</para>
121 <term><constant>-EINVAL</constant></term>
123 <listitem><para>The input parameter <parameter>call</parameter> is
124 <constant>NULL</constant>.</para>
126 <para>Message <parameter>call</parameter> is not a method call message.</para>
128 <para>Message <parameter>call</parameter> is not attached to a bus.</para>
130 <para>The error parameter <parameter>e</parameter> to
131 <function>sd_bus_reply_method_error()</function> is not set, see
132 <citerefentry><refentrytitle>sd_bus_error_is_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
138 <term><constant>-EPERM</constant></term>
140 <listitem><para>Message <parameter>call</parameter> has been sealed.
145 <term><constant>-ENOTCONN</constant></term>
147 <listitem><para>The bus to which message <parameter>call</parameter> is attached is not
148 connected.</para></listitem>
152 <term><constant>-ENOMEM</constant></term>
154 <listitem><para>Memory allocation failed.</para></listitem>
158 <para>In addition, any error returned by
159 <citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>1</manvolnum></citerefentry>
160 may be returned.</para>
164 <xi:include href="libsystemd-pkgconfig.xml" />
167 <title>See Also</title>
170 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
171 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
172 <citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>