Topic "error"

ERROR			Monash Image Library				ERROR

When an error is encountered by the image library the subroutine i_error
is called. The first parameter specifies one of four error levels:

	I_INFORM  means a comment,
	I_WARNING means a non fatal error or possible error,
	I_FATAL   means a fatal error,
	I_PANIC   means a fatal error (reserved for the image library itself).

In fact, I_INFORM, I_WARNING, etc are macros defined in image.h and expand
into two parameters but this need not concern the user.  Users of the image
library may use i_error to report errors.  The error level parameter must be
followed by a printf style format string and (optionally) any arguments for
this format. For example:

	i_error(I_FATAL,"invalid image size: %d rows by %d columns",rows,cols);

If I_FATALSYS is used instead of I_FATAL or I_PANICSYS instead of I_PANIC
then perror is used to print any error messages.  I_FATALSYS and I_PANICSYS
are at the same error level as I_FATAL and I_PANIC respectively.

The default behaviour of i_error is to print the error message on stderr and
call the error handler for that error level.  The error handlers are
described later after error reporting has been discussed.  An enumeration
type is provided for control of warning level actions:

	enum warning_level {i_inform, i_warning, i_fatal, i_panic, i_none}.

The environment variable I_WARN_LEVEL is used to specify the default minimum
warning level reported on stderr and procedures are provided which can be
used to override the default.  If the environment variable I_WARN_LEVEL is
not defined then the default is i_inform.  For example (csh):

	setenv I_WARN_LEVEL i_fatal

will only allow warnings at fatal level and above to be reported on stderr.

The two procedures set_warn_level and get_warn_level with declarations:

	set_warn_level(warning_level);
	warning_level get_warn_level();

can be used to override the default warning level and (by means of calling
get_warn_level before changing it) to restore it to its default value.

The procedure i_on_error can be used to set the error handler for a
particular warning level.  The handler is called regardless of the current
warning level. Since image library procedures do not expect
i_error(I_FATAL,...) and i_error(I_PANIC,...) to return you should normally
provide handlers which do not return for these error levels.  The
declaration for i_on_error is:

	void i_on_error(enum i_warn_level w, void handler(int));

The default error handlers are:
	
	I_INFORM: do nothing,
	I_WARNING: do nothing,
	I_FATAL: exit,
	I_PANIC: core dump then exit.

Related Functions

ierror indicates an error level and error message. Note that the function prototype below is a psuedo prototype. The LEVEL argument is a macro defined in image.h which must be one of I_INFORM, I_WARNING, I_FATAL, I_PANIC, I_FATALSYS or I_PANICSYS. The format and other arguments are as for printf.
ion_error register an error handler for error level.

Other Topics

index | userguide | full | arithmetic | basic | binary | blocks | colour | compress | display | docs | fft | hist | image | io | makefile | masks | memory | misc | morph | pixel | rgb | stats | transform | error | mapping