---
name: "VistaIOSetErrorHandler"
section: "3"
platform: "linux"
package: "libvistaio-dev"
version: "1.2.19-3+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/VistaIOSetErrorHandler"
---

# VistaIOSetErrorHandler(3)

register a procedure to be called on any fatal error

## NAME

VistaIOSetErrorHandler - register a procedure to be called on any fatal error

## SYNOPSIS

```
void VistaIOSetErrorHandler (VistaIOErrorHandler *handler);
```

**typedef void VistaIOErrorHandler (VistaIOStringConst** *message***);**

**void VistaIODefaultError (VistaIOStringConst** *message***);**

## ARGUMENTS

- *handler*

  **Specifies the new fatal error handler.**

- *message*

  **Specifies a null-terminated error message string to be reported.**

## DESCRIPTION

**VistaIOSetErrorHandler registers a procedure,** *handler***, as the fatal** **error handler. That procedure is called by [VistaIOError(3)](/VistaIOError/3.md) or by** **VistaIOSystemError(3) to report any fatal error. When called, it is passed** **a string,** *message***, containing a textual description of the error.**

**Only one procedure serves as the fatal error handler at any one time.**

**Prior to the first call to VistaIOSetErrorHandler, the procedure**  **VistaIODefaultError is the fatal error handler. This procedure will** **write the error message to the standard error stream, then terminate** **the program by calling [exit(3)](/exit/3.md) with a status value of 1.**  **VistaIODefaultError can be re-established as the fatal error handler** **at any time by calling VistaIOSetErrorHandler with a**  **NULL** **argument.**

## RETURN VALUES

**A fatal error handler should never return.**

## 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 ALSO

[**VistaIOError**(3)](/VistaIOError/3.md), [**VistaIOSetWarningHandler**(3)](/VistaIOSetWarningHandler/3.md),

## AUTHOR

**Art Pope \<pope@cs.ubc.ca\>**

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