VistaIOSetErrorHandler(3)

✨ VistaIOSetErrorHandler ✨

okay bestie, so this is a page from the Library Functions Manual πŸ’… and it's literally all about VistaIOSetErrorHandler(3) β€” the little function that decides who gets to scream when something goes catastrophically wrong. no cap, this is important stuff.


πŸ’– NAME πŸ’–

VistaIOSetErrorHandler β€” register a procedure to be called on any fatal error

like, you're literally hiring a designated panic-yeller. 🫢


🌸 SYNOPSIS 🌸

void VistaIOSetErrorHandler (VistaIOErrorHandler *handler);

typedef void VistaIOErrorHandler (VistaIOStringConst message);

void VistaIODefaultError (VistaIOStringConst message);

so we've got the setter, the type of the handler function, and the default handler that ships with the library. three little besties. πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • handler β€” Specifies the new fatal error handler. this is who you're handing the mic to when everything's on fire. πŸ”₯
  • message β€” Specifies a null-terminated error message string to be reported. it's the tea being spilled, in char array form. πŸ’Œ

⭐ DESCRIPTION ⭐

VistaIOSetErrorHandler registers a procedure, handler, as the fatal error handler. that procedure gets called by VistaIOError(3) or by VistaIOSystemError(3) whenever they need to report any fatal error. and when it's called, it's passed a string, message, containing a textual description of the error. so like, the handler gets told exactly what went wrong. iconic behaviour honestly. ✨

Only one procedure serves as the fatal error handler at any one time. yep β€” one (1) main character. no ensemble cast, no group chat, just one handler holding the crown. πŸ‘‘

Prior to the first call to VistaIOSetErrorHandler, the procedure VistaIODefaultError is the fatal error handler. and what does this default diva do? she will write the error message to the standard error stream, then terminate the program by calling exit(3) with a status value of 1. that's it, that's the whole vibe: say the thing, then dip. πŸ’€

VistaIODefaultError can be re-established as the fatal error handler at any time by calling VistaIOSetErrorHandler with a NULL argument. so if you ever miss the original girlie, she's one NULL away. lowkey comforting. πŸ₯Ή


🌈 RETURN VALUES 🌈

A fatal error handler should never return.

bestie. NEVER. it does not come back. it is not on a round trip. if it returns, that's not a "quirky handler", that's a problem. periodt. πŸ’…

πŸŽ€ EXAMPLES πŸŽ€

To adopt an error handler that writes messages both to the standard error stream and to a log file, one might do the following:

FILE *log_file;

void MyErrorHandler (message)
     VistaIOStringConst message;
{
     fputs (message, stderr);
     fputs (message, log_file);
     exit (1);
}

int main (...)
{
     ...
     log_file = fopen ("log", "w");
     VistaIOSetErrorHandler (MyErrorHandler);
     ...
}

see how MyErrorHandler writes the message to stderr and to log_file, then calls exit (1)? that's the move. the message goes everywhere it needs to go, and then the program says goodbye. πŸ“


πŸ’œ SEE ALSO πŸ’œ


🧚 AUTHOR 🧚

Art Pope <pope@cs.ubc.ca>

Adaption to vistaio: Gert Wollny <gw.fossdev@gmail.com>


okay so that's the whole page, bestie!! 🌸 and for the cute sign-off: this is VistaIO Version 1.2.14, dated 16 February 1994 β€” yes she's a vintage queen and she still ate πŸ’…βœ¨ πŸ¦‹