#include <tiffio.h>
#include <stdarg.h>
void TIFFError(const char *module, const char *fmt, ...)
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt, ...)
typedef void (*TIFFErrorHandler)(const char *module, const char *fmt, va_list ap)
typedef void (*TIFFErrorHandlerExt)(thandle_t fd, const char *module, const char *fmt, va_list ap)
TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler)
TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler)


TIFFError() invokes the library-wide error handling function to (normally) write an error message to stderr. The fmt parameter is a printf() format string, and any number arguments can be supplied. The module parameter, if non-zero, is printed before the message; it typically is used to identify the software module in which an error is detected.

Applications that desire to capture control in the event of an error should use TIFFSetErrorHandler() to override the default error handler. A NULL (0) error handling function may be installed to suppress error messages.

The function TIFFErrorExt() provides a file handle. Within libtiff TIFFErrorExt() is called passing tif->tif_clientdata as fd, which represents the TIFF file handle (file descriptor).

With TIFFSetErrorHandlerExt() an extra error handler can be setup in order to write to a file. The file handle needs to be stored in tif->tif_clientdata if the libtiff internal errors shall also be written to that file.

Note that, starting with libtiff 4.5, a per-TIFF handler may also be installed with TIFFOpenExt() or TIFFClientOpenExt()


Both functions TIFFError() and TIFFErrorExt() each attempt to call both handler functions if they are defined. First TIFFErrorHandler() is called and then TIFFErrorHandlerExt(). However, TIFFError() passes a "0" as a file handle to TIFFErrorHandlerExt().

Return values

TIFFSetErrorHandler() and TIFFSetErrorHandlerExt() returns a reference to the previous error handling function.

See also

TIFFWarning (3tiff), libtiff (3tiff), printf (3)