'\" t .TH "SD_BUS_MESSAGE_NEW_METHOD_ERROR" "3" "" "systemd 256.7" "sd_bus_message_new_method_error" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" sd_bus_message_new_method_error, sd_bus_message_new_method_errorf, sd_bus_message_new_method_errno, sd_bus_message_new_method_errnof \- Create an error reply for a method call .SH "SYNOPSIS" .sp .ft B .nf #include .fi .ft .HP \w'int\ sd_bus_message_new_method_error('u .BI "int sd_bus_message_new_method_error(sd_bus_message\ *" "call" ", sd_bus_message\ **" "m" ", const\ sd_bus_error\ *" "e" ");" .HP \w'int\ sd_bus_message_new_method_errorf('u .BI "int sd_bus_message_new_method_errorf(sd_bus_message\ *" "call" ", sd_bus_message\ **" "m" ", const\ char\ *" "name" ", const\ char\ *" "format" ", \&...);" .HP \w'int\ sd_bus_message_new_method_errno('u .BI "int sd_bus_message_new_method_errno(sd_bus_message\ *" "call" ", sd_bus_message\ **" "m" ", int\ " "error" ", const\ sd_bus_error\ *" "p" ");" .HP \w'int\ sd_bus_message_new_method_errnof('u .BI "int sd_bus_message_new_method_errnof(sd_bus_message\ *" "call" ", sd_bus_message\ **" "m" ", int\ " "error" ", const\ char\ *" "format" ", \&...);" .SH "DESCRIPTION" .PP The \fBsd_bus_message_new_method_error()\fR function creates a new bus message object that is an error reply to the \fIcall\fR message, and returns it in the \fIm\fR output parameter\&. The error information from error \fIe\fR is appended: the \fIname\fR field of \fIe\fR is used as the error identifier in the reply header (for example an error name such as "org\&.freedesktop\&.DBus\&.Error\&.NotSupported" or the equivalent symbolic \fBSD_BUS_ERROR_NOT_SUPPORTED\fR), and the \fImessage\fR field is set as the human readable error message string if present\&. The error \fIe\fR must have the \fIname\fR field set, see \fBsd_bus_error_is_set\fR(3)\&. .PP The \fBsd_bus_message_new_method_errorf()\fR function creates an error reply similarly to \fBsd_bus_message_new_method_error()\fR, but instead of a ready error structure, it takes an error identifier string \fIname\fR, plus a \fBprintf\fR(3) format string \fIformat\fR and corresponding arguments\&. An error reply is sent with the error identifier \fIname\fR and the formatted string as the message\&. \fIname\fR and \fIformat\fR must not be \fBNULL\fR\&. .PP The \fBsd_bus_message_new_method_errno()\fR function creates an error reply similarly to \fBsd_bus_message_new_method_error()\fR, but in addition to the error structure \fIp\fR, it takes an \fBerrno\fR(3) error value in parameter \fIerror\fR\&. If the error \fIp\fR is set (see \fBsd_bus_error_is_set\fR(3)), it is used in the reply\&. Otherwise, \fIerror\fR is translated to an error identifier and used to create a new error structure using \fBsd_bus_error_set_errno\fR(3) and that is used in the reply\&. (If \fIerror\fR is zero, no error is actually set, and an error reply with no information is created\&.) .PP The \fBsd_bus_message_new_method_errnof()\fR function creates an error reply similarly to \fBsd_bus_message_new_method_error()\fR\&. It takes an \fBerrno\fR(3) error value in parameter \fIerror\fR, plus a \fBprintf\fR(3) format string \fIformat\fR and corresponding arguments\&. "%m" may be used in the format string to refer to the error string corresponding to the specified errno code\&. The error message is initialized using the error identifier generated from \fBerror\fR and the formatted string\&. (If \fIerror\fR is zero, no error is actually set, and an error reply with no information is created\&.) .SH "RETURN VALUE" .PP These functions return 0 if the error reply was successfully created, and a negative errno\-style error code otherwise\&. .SS "Errors" .PP Returned errors may indicate the following problems: .PP \fB\-EINVAL\fR .RS 4 The call message \fIcall\fR or the output parameter \fIm\fR are \fBNULL\fR\&. .sp Message \fIcall\fR is not a method call message\&. .sp The error \fIe\fR parameter to \fBsd_bus_message_new_method_error()\fR is not set, see \fBsd_bus_error_is_set\fR(3)\&. .RE .PP \fB\-EPERM\fR .RS 4 Message \fIcall\fR has been sealed\&. .RE .PP \fB\-ENOTCONN\fR .RS 4 The bus to which message \fIcall\fR is attached is not connected\&. .RE .PP \fB\-ENOMEM\fR .RS 4 Memory allocation failed\&. .RE .SH "NOTES" .PP Functions described here are available as a shared library, which can be compiled against and linked to with the \fBlibsystemd\fR\ \&\fBpkg-config\fR(1) file\&. .PP The code described here uses \fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call \fBsetenv\fR(3) from a parallel thread\&. It is recommended to only do calls to \fBsetenv()\fR from an early phase of the program when no other threads have been started\&. .SH "SEE ALSO" .PP \fBsystemd\fR(1), \fBsd-bus\fR(3)