VISTAIOSETWARNINGHANDLER(3)

πŸ’– VistaIOSetWarningHandler β€” Library Functions Manual πŸ’–

okay bestie, gather round, because we're about to talk about how you tell vistaio what to do when something goes slightly wrong but not, like, catastrophic. this is VistaIOSetWarningHandler(3) and she's giving "let me set up my warning handler" energy ✨


🌸 NAME 🌸

VistaIOSetWarningHandler β€” register a procedure to be called on any nonfatal error 🫢


✨ SYNOPSIS ✨

void VistaIOSetWarningHandler (VistaIOWarningHandler *handler)

typedef void VistaIOWarningHandler (VistaIOStringConst message);

void VistaIODefaultWarning (VistaIOStringConst message);

πŸŽ€ ARGUMENTS πŸŽ€

  • handler β€” this is the new nonfatal error handler you're handing over. the new main character, if you will πŸ‘‘
  • message β€” a null-terminated error message string that's getting reported. yes it's a string, yes it ends in a null, no we don't make the rules πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, VistaIOSetWarningHandler registers a procedure β€” that's your handler β€” as the nonfatal error handler. that procedure gets called by VistaIOWarning(3) or by VistaIOSystemWarning(3) whenever there's a nonfatal error to report. and when it gets called? it's passed a string, message, that contains a textual description of whatever went wrong. lowkey iconic behavior 🌈

only one procedure can serve as the nonfatal error handler at any one time. one. singular. no polycule of handlers, sorry πŸ’€

before the very first call to VistaIOSetWarningHandler, the procedure VistaIODefaultWarning is the nonfatal error handler. what does she do? she writes the error message to the standard error stream, then returns. that's it. no notes. πŸ“

heads up bestie: VistaIODefaultWarning can be re-established as the fatal error handler at any time β€” literally any time β€” by calling VistaIOSetWarningHandler with a NULL argument. yes, it says "fatal" there. we're keeping it exactly as the manpage says it, periodt πŸ’œ

🌈 EXAMPLES 🌈

so say you want a warning handler that writes messages both to the standard error stream and to a log file. you might do the following, no cap:

FILE *log_file;

void MyWarningHandler (message)
     VistaIOStringConst message;
{
     fputs (message, stderr);
     fputs (message, log_file);
}

int main (...)
{
     ...
     log_file = fopen ("log", "w");
     VistaIOSetWarningHandler (MyWarningHandler);
     ...
}

see how she's just vibing? fputs twice, once to stderr, once to log_file, and the handler is registered in main. obsessed. πŸŽ€


πŸ‘€ SEE ALSO πŸ‘€

  • VistaIOWarning(3)
  • VistaIOSetErrorHandler(3)

πŸ’œ AUTHOR πŸ’œ

  • Art Pope <pope@cs.ubc.ca>
  • Adaption to vistaio: Gert Wollny <gw.fossdev@gmail.com>

and that's the whole page, bestie!! this was VistaIO Version 1.2.14, dated 16 February 1994 β€” yeah she's vintage, she's an elder, and she still slays πŸ’…βœ¨ thanks for reading VistaIOSetWarningHandler(3), mwah πŸ«ΆπŸ’–