1SD_BUS_MESSAGE_NEW_METHODs_dE_RbRuOsR_(m3e)ssage_new_meStDh_oBdU_Se_rMrEoSrSAGE_NEW_METHOD_ERROR(3)
2
3
4
6 sd_bus_message_new_method_error, sd_bus_message_new_method_errorf,
7 sd_bus_message_new_method_errno, sd_bus_message_new_method_errnof -
8 Create a an error reply for a method call
9
11 #include <systemd/sd-bus.h>
12
13 int sd_bus_message_new_method_error(sd_bus_message *call,
14 sd_bus_message **m,
15 const sd_bus_error *e);
16
17 int sd_bus_message_new_method_errorf(sd_bus_message *call,
18 sd_bus_message **m,
19 const char *name,
20 const char *format, ...);
21
22 int sd_bus_message_new_method_errno(sd_bus_message *call,
23 sd_bus_message **m, int error,
24 const sd_bus_error *p);
25
26 int sd_bus_message_new_method_errnof(sd_bus_message *call,
27 sd_bus_message **m, int error,
28 const char *format, ...);
29
31 The sd_bus_message_new_method_error() function creates a new bus
32 message object that is an error reply to the call message, and returns
33 it in the m output parameter. The error information from error e is
34 appended: the name field of e is used as the error identifier in the
35 reply header (for example an error name such as
36 "org.freedesktop.DBus.Error.NotSupported" or the equivalent symbolic
37 SD_BUS_ERROR_NOT_SUPPORTED), and the message field is set as the human
38 readable error message string if present. The error e must have the
39 name field set, see sd_bus_error_is_set(3).
40
41 The sd_bus_message_new_method_errorf() function creates an error reply
42 similarly to sd_bus_message_new_method_error(), but instead of a ready
43 error structure, it takes an error identifier string name, plus a
44 printf(3) format string format and corresponding arguments. An error
45 reply is sent with the error identifier name and the formatted string
46 as the message. name and format must not be NULL.
47
48 The sd_bus_message_new_method_errno() function creates an error reply
49 similarly to sd_bus_message_new_method_error(), but in addition to the
50 error structure p, it takes an errno(3) error value in parameter error.
51 If the error p is set (see sd_bus_error_is_set(3)), it is used in the
52 reply. Otherwise, error is translated to an error identifier and used
53 to create a new error structure using sd_bus_error_set_errno(3) and
54 that is used in the reply. (If error is zero, no error is actually set,
55 and an error reply with no information is created.)
56
57 The sd_bus_message_new_method_errnof() function creates an error reply
58 similarly to sd_bus_message_new_method_error(). It takes an errno(3)
59 error value in parameter error, plus a printf(3) format string format
60 and corresponding arguments. "%m" may be used in the format string to
61 refer to the error string corresponding to the specified errno code.
62 The error message is initialized using the error identifier generated
63 from error and the formatted string. (If error is zero, no error is
64 actually set, and an error reply with no information is created.)
65
67 These functions return 0 if the error reply was successfully created,
68 and a negative errno-style error code otherwise.
69
70 Errors
71 Returned errors may indicate the following problems:
72
73 -EINVAL
74 The call message call or the output parameter m are NULL.
75
76 Message call is not a method call message.
77
78 The error error parameter to sd_bus_message_new_method_error is not
79 set, see sd_bus_error_is_set(3).
80
81 -EPERM
82 Message call has been sealed.
83
84 -ENOTCONN
85 The bus to which message call is attached is not connected.
86
87 -ENOMEM
88 Memory allocation failed.
89
91 These APIs are implemented as a shared library, which can be compiled
92 and linked to with the libsystemd pkg-config(1) file.
93
95 systemd(1), sd-bus(3)
96
97
98
99systemd 245 SD_BUS_MESSAGE_NEW_METHOD_ERROR(3)