aboutsummaryrefslogtreecommitdiff
path: root/doc/ref/general/util-exceptions.texi
blob: 4c2b432d76d448f3829e10c18c85afa47e434c85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@node Exception & Warning Utilities
@section Exception & Warning Utilities
@anchor{warning}

Warnings are like exceptions, but only fatal when wanted.

@code{(hnh util exceptions)}

@defun warning fmt args ...
Emit a warning.

If the parameter @var{warnings-are-errors} is true, then an exception
of type @code{'warning} will be raised, with @var{fmt} and @var{args}
as arguments.

If that parameter is false, then the procedure in
@var{warning-handler} will instead be called.
@end defun

@deftp {parameter} warning-handler
Parameter containing proceudre which will be called for non-throwing
warnings. This procedure is assumed by the program to log the warning
in some way, and continue program flow. But anything goes.

The procedure is given a format specifier (as per Scheme's basic
@code{format}), along with the correct number of arguments.
@end deftp

@deftp {parameter} warnings-are-errors
Boolean parameter, which if set causes warnings to be thrown as exceptions.
@end deftp

@defun fatal fmt args ...
Display the message in fmt, populated with args, then raises the UNIX
signal SIGINT, which kills the program.
@end defun

@defun filter-stack pred? stack
@c TODO document me
@end defun


@defun unreachable procedure fmt args
Marks that a code path should be unreachable. Throws an exception
which should never be caught (an @code{(exit -1)} would also have
worked, but would make debugging harder).

@var{procedure} is the procedure which reached an ``impossible''
state, @var{fmt} a format string, and @var{args} arguments to that
format string.
@end defun