MEMCACHED_LAST_ERROR_ERRNO(3)

πŸ’– MEMCACHED_LAST_ERROR_ERRNO πŸ’–

okay bestie, come sit with me. this is a page from libmemcached-awesome, manual section 3, and it's literally the ✨ receipts ✨ page β€” it's how you ask your memcached object "hey. what just happened. what went wrong." 🫢


🌸 NAME 🌸

memcached_last_error_errno β€” libmemcached Documentation

like yes, that's the whole name, it's giving "we named it after one function but it's actually a lil trio" energy πŸ’…


✨ SYNOPSIS ✨

first things first, you gotta pull the header in:

#include <libmemcached/memcached.h>

and then β€” not me forgetting the link flag β€” compile and link with:

-libmemcached

wait, no, that's the flag, spelled exactly like this:

-lmemcached

do NOT skip that one, she is required fr fr.

so here's the whole squad, all three functions, all three signature-identical on the input side πŸ‘‘

memcached_return_t memcached_last_error(const memcached_st *ptr)

Parameters

  • ptr β€” pointer to an initialized memcached_st struct

Returns

  • memcached_return_t indicating success of last operation
const char *memcached_last_error_message(const memcached_st *ptr)

Parameters

  • ptr β€” pointer to an initialized memcached_st struct

Returns

  • message describing the status of last operation
int memcached_last_error_errno(const memcached_st *ptr)

Parameters

  • ptr β€” pointer to an initialized memcached_st struct

Returns


πŸ¦‹ DESCRIPTION πŸ¦‹

Retrieve error codes and messages. πŸŽ€

that's it. that's the whole vibe. she does one thing and she ate. ✨


🌈 RETURN VALUE 🌈

okay so here's the tea on each one, and lowkey this is the part you actually need, so pay attention bestie πŸ’…

  • memcached_last_error() β€” returns the last error code.
  • memcached_last_error_message() β€” returns the last error message. and here's the cute part: if this error came from a specific server, its hostname and port will be provided in the error message. 🫢 Any error message will be returned as 'const char *' which does not need to be de-allocated β€” so don't you dare free() her, she's not yours, she's borrowed. πŸ’€ And NULL will be returned if no error has occurred.
  • memcached_last_error_errno() β€” returns any last local error code obtained from errno(3). yes, the local one. main character energy, but make it errno. πŸ”₯
not me reminding you that NULL means "no error" and not "something exploded" β€” the two are NOT the same thing and confusing them is how you end up in the group chat asking why your code is sad for no reason 😭

πŸ‘‘ SEE ALSO πŸ‘‘

go read these too, they're all iconic in their own way:


and that's the whole page, no notes, periodt. πŸŽ€

this was version 1.1, dated Jul 24, 2025, from the libmemcached-awesome girlies β€” k bye, go check your errno, ily πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from