allegro_error(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

🌸 allegro_error β€” the receipts of your last Allegro oopsie πŸ’…

okay so bestie, welcome to the allegro_error page of the Allegro manual ✨ pull up a chair, grab a strawberry πŸ“, we're about to talk about the one variable that always knows what went wrong and is never not a little bit dramatic about it.


✨ NAME ✨

allegro_error β€” she stores the last Allegro error message. that's it, that's the job, and she eats every single time πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

extern char allegro_error[ALLEGRO_ERROR_SIZE];

literally just one little global char array bestie, no cap πŸŽ€


πŸ’œ DESCRIPTION πŸ’œ

so this is the text string that set_gfx_mode(), install_sound() and a bunch of other functions use to spill the tea about error messages β˜• when one of them fails and you actually wanna tell your user why it flopped, this is the place to look for a description of the problem. she's the main character of the fail state, periodt πŸ‘‘

example time, watch her work:

void abort_on_error(const char *message)
{
   if (screen != NULL)
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);

   allegro_message("%s.\nLast Allegro error `%s'\n",
                   message, allegro_error);
   exit(-1);
}
...
   if (some_allegro_function() == ERROR_CODE)
      abort_on_error("Error calling some function!");

see how she just drops right into that allegro_message like she owns the place?? iconic behavior honestly πŸ’… notice the %s slots β€” your own message first, then allegro_error itself spilling the actual details. and yes, that exit(-1) at the end is doing the most, but sometimes you just gotta ✨ leave ✨.

🫢 real talk: read allegro_error right after the function fails, bestie. she's a "last message" girlie β€” she only remembers the most recent one, so don't go dilly-dallying before you check her.

πŸŽ€ SEE ALSO πŸŽ€

  • set_gfx_mode(3) β€” the graphics mode setter who's gonna be filling in that error string a whole lot 🌈
  • install_sound(3) β€” the sound setup bestie doing the exact same thing when the audio goes sideways πŸ”₯

and that's the whole vibe check, bestie ✨ go forth and handle your errors like the icon you are πŸ‘‘πŸ’–

Allegro Β· version 4.4.3 Β· allegro_error(3) β€” mwah, tysm for reading, ilysm, see u in the next manpage πŸ¦‹πŸ’œπŸŽ€

πŸ“¦ where this page comes from