---
name: "ne_set_error"
section: "3"
platform: "linux"
package: "libneon27-dev"
version: "0.34.2-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ne_get_error"
---

# ne\_set\_error(3)

error handling for HTTP sessions

Part of [ne\_get\_error(3)](/ne_get_error/3.md).

## NAME

ne\_get\_error, ne\_set\_error - error handling for HTTP sessions

## SYNOPSIS

```
#include <ne_session.h>
```

**const char \*ne\_get\_error(ne\_sesssion \****session***);**

**void ne\_set\_error(ne\_sesssion \****session***, const char \****format***, ...);**

## DESCRIPTION

The session error string is used to store any human-readable error information associated with any errors which occur whilst using the HTTP session.

The **ne\_get\_error** function returns the current session error string. This string persists only until it is changed by a subsequent operation on the session. If localisation was enabled at build time, and if necessary enabled at run-time if necessary using ne\_i18n\_init, the returned string may have been translated into the user's current locale.

The **ne\_set\_error** function can be used to set a new session error string, using a **printf**-style format string interface.

## RETURN VALUE

**ne\_set\_error** returns a constant NUL-terminated string. In the default English locale, the returned string will *not* have a terminating “.” period character.

## EXAMPLES

Retrieve the current error string:

```
ne_session *sess = ne_session_create(...);
...
printf("Error was: %s\n", ne_get_error(sess));
```

Set a new error string:

```
ne_session *sess = ne_session_create(...);
...
ne_set_error(sess, "Response missing header %s", "somestring");
```

## COPYRIGHT

Copyright © 2001-2024 Joe Orton\
