---
name: "sd_bus_message_is_method_error"
section: "3"
platform: "linux"
package: "libsystemd-dev"
version: "257.13-1~deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sd_bus_message_get_type"
---

# sd\_bus\_message\_is\_method\_error(3)

Query bus message addressing/credentials metadata

Part of [sd\_bus\_message\_get\_type(3)](/sd_bus_message_get_type/3.md).

## NAME

sd\_bus\_message\_get\_type, sd\_bus\_message\_get\_error, sd\_bus\_message\_get\_errno, sd\_bus\_message\_get\_creds, sd\_bus\_message\_is\_signal, sd\_bus\_message\_is\_method\_call, sd\_bus\_message\_is\_method\_error - Query bus message addressing/credentials metadata

## SYNOPSIS

```
#include <systemd/sd-bus.h>
```

**int sd\_bus\_message\_get\_type(sd\_bus\_message \****m***, uint8\_t \****type***);**

**sd\_bus\_error\* sd\_bus\_message\_get\_error(sd\_bus\_message \****m***);**

**int sd\_bus\_message\_get\_errno(sd\_bus\_message \****m***);**

**sd\_bus\_creds\* sd\_bus\_message\_get\_creds(sd\_bus\_message \****m***);**

**int sd\_bus\_message\_is\_signal(sd\_bus\_message \****m***, const char \****interface***, const char \****member***);**

**int sd\_bus\_message\_is\_method\_call(sd\_bus\_message \****m***, const char \****interface***, const char \****member***);**

**int sd\_bus\_message\_is\_method\_error(sd\_bus\_message \****m***, const char \****name***);**

## DESCRIPTION

**sd\_bus\_message\_get\_type()** returns the type of a message in the output parameter *type*, one of **SD\_BUS\_MESSAGE\_METHOD\_CALL**, **SD\_BUS\_MESSAGE\_METHOD\_RETURN**, **SD\_BUS\_MESSAGE\_METHOD\_ERROR**, **SD\_BUS\_MESSAGE\_SIGNAL**. This type is either specified as a parameter when the message is created using [**sd\_bus\_message\_new**(3)](/sd_bus_message_new/3.md), or is set automatically when the message is created using [**sd\_bus\_message\_new\_signal**(3)](/sd_bus_message_new_signal/3.md), [**sd\_bus\_message\_new\_method\_call**(3)](/sd_bus_message_new_method_call/3.md), [**sd\_bus\_message\_new\_method\_error**(3)](/sd_bus_message_new_method_error/3.md) and similar functions.

**sd\_bus\_message\_get\_error()** returns the error stored in the message *m*, if there is any. Otherwise, it returns **NULL**. **sd\_bus\_message\_get\_errno()** returns the error stored in the message *m* as a positive errno-style value, if there is any. Otherwise, it returns zero. Errors are mapped to errno values according to the default and any additional registered error mappings. See [**sd-bus-errors**(3)](/sd-bus-errors/3.md) and [**sd\_bus\_error\_add\_map**(3)](/sd_bus_error_add_map/3.md).

**sd\_bus\_message\_get\_creds()** returns the message credentials attached to the message *m*. If no credentials are attached to the message, it returns **NULL**. Ownership of the credentials instance is not transferred to the caller and hence should not be freed.

**sd\_bus\_message\_is\_signal()** checks if message *m* is a signal message. If *interface* is non-null, it also checks if the message has the same interface set. If *member* is non-null, it also checks if the message has the same member set. Also see [**sd\_bus\_message\_new\_signal**(3)](/sd_bus_message_new_signal/3.md). It returns true when all checks pass.

**sd\_bus\_message\_is\_method\_call()** checks if message *m* is a method call message. If *interface* is non-null, it also checks if the message has the same interface set. If *member* is non-null, it also checks if the message has the same member set. Also see [**sd\_bus\_message\_new\_method\_call**(3)](/sd_bus_message_new_method_call/3.md). It returns true when all checks pass.

**sd\_bus\_message\_is\_method\_error()** checks if message *m* is an error reply message. If *name* is non-null, it also checks if the message has the same error identifier set. Also see [**sd\_bus\_message\_new\_method\_error**(3)](/sd_bus_message_new_method_error/3.md). It returns true when all checks pass.

## RETURN VALUE

On success, these functions (except **sd\_bus\_message\_get\_error()** and **sd\_bus\_message\_get\_creds()**) return a non-negative integer. On failure, they return a negative errno-style error code. **sd\_bus\_message\_get\_errno()** always returns a non-negative integer, even on failure.

### Errors

Returned errors may indicate the following problems:

**-EINVAL**

The message parameter *m* or an output parameter is **NULL**.

## NOTES

Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/pkg-config/1.md) file.

The code described here uses [**getenv**(3)](/getenv/3.md), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call [**setenv**(3)](/setenv/3.md) from a parallel thread. It is recommended to only do calls to **setenv()** from an early phase of the program when no other threads have been started.

## HISTORY

**sd\_bus\_message\_get\_type()**, **sd\_bus\_message\_is\_signal()**, **sd\_bus\_message\_is\_method\_call()**, and **sd\_bus\_message\_is\_method\_error()** were added in version 240.

**sd\_bus\_message\_get\_error()**, **sd\_bus\_message\_get\_errno()**, and **sd\_bus\_message\_get\_creds()** were added in version 246.

## SEE ALSO

[**systemd**(1)](/systemd/1.md), [**sd-bus**(3)](/sd-bus/3.md), [**sd\_bus\_message\_new**(3)](/sd_bus_message_new/3.md), [**sd\_bus\_message\_set\_destination**(3)](/sd_bus_message_set_destination/3.md), [**sd-bus-errors**(3)](/sd-bus-errors/3.md), [**sd\_bus\_error\_add\_map**(3)](/sd_bus_error_add_map/3.md)
