af_error(3)

πŸ’– af_error β€” AtFS error handling, bestie edition πŸ’–

okay so this is the af_error(3) page from the Attribute Filesystem (AtFS) era, and it's literally your little first-aid kit for when AtFS stuff goes sideways. four icons in one: af_errno, af_perror, af_errmsg, and af_cleanup. no cap, you're gonna want these in your group chat (your code) fr fr 🫢


✨ SYNOPSIS ✨

#include <atfs.h>

int  af_errno

void af_perror (char *string)

char *af_errmsg (char *string)

int  af_cleanup (void)

🌸 DESCRIPTION 🌸

πŸ’… af_errno β€” the main character error variable

af_errno is the global AtFS error number variable. the way it works: if an AtFS function returns with an error, af_errno gets set to indicate the appropriate error number. periodt.

heads up bestie πŸ’€ it does not get cleared upon successful calls. so don't go reading it after a win and assuming it means something β€” it's still holding onto the last L.

and if you want the whole lore of error codes? the af_intro(3) manual page gives an overview of all of them. go read it, iykyk ✨

πŸŽ€ af_perror β€” the messenger

af_perror produces a short error message of the form described in perror(3). this message will be written to standard error.

here's the vibe check: if the last error encountered during an AtFS application was an AtFS-specific error, a corresponding message is generated. otherwise, af_perror calls perror(3). so it always delivers, one way or another. slay πŸ’…

πŸ¦‹ af_errmsg β€” same energy, but it returns

af_errmsg does the same as af_perror but returns the message rather than writing to standard error. it's giving "i'll hand you the tea instead of shouting it across the room."

⚠️ the result string resides in static memory and hence will be overwritten on subsequent calls of af_errmsg. so if you're holding onto that pointer thinking it's yours forever... it's not. copy it, bestie, or it's gone 😭

🧚 af_cleanup β€” the responsible one

af_cleanup serves as a cleanup routine upon premature termination of an AtFS application. it removes temporary files and frees all allocated memory. not me being the friend who actually cleans up the party 🫢 iconic behaviour, honestly.


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! this one came from AtFS-1.71, dated Fri Jun 25 14:33:06 1993 β€” so yeah, vintage, but the energy is timeless. go forth and handle your errors like the icon you are πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from