Debian Codegraph @

doc/throw.n

raw
1 '\"
2 '\" Copyright (c) 2008 Donal K. Fellows
3 '\"
4 '\" See the file "license.terms" for information on usage and redistribution
5 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\"
7 .TH throw n 8.6 Tcl "Tcl Built-In Commands"
8 .so man.macros
9 .BS
10 '\" Note: do not modify the .SH NAME line immediately below!
11 .SH NAME
12 throw \- Generate a machine-readable error
13 .SH SYNOPSIS
14 \fBthrow\fI type message\fR
15 .BE
16 .SH DESCRIPTION
17 .PP
18 This command causes the current evaluation to be unwound with an error. The
19 error created is described by the \fItype\fR and \fImessage\fR arguments:
20 \fItype\fR must contain a list of words describing the error in a form that is
21 machine-readable (and which will form the error-code part of the result
22 dictionary), and \fImessage\fR should contain text that is intended for
23 display to a human being.
24 .PP
25 The stack will be unwound until the error is trapped by a suitable \fBcatch\fR
26 or \fBtry\fR command. If it reaches the event loop without being trapped, it
27 will be reported through the \fBbgerror\fR mechanism. If it reaches the top
28 level of script evaluation in \fBtclsh\fR, it will be printed on the console
29 before, in the non-interactive case, causing an exit (the behavior in other
30 programs will depend on the details of how Tcl is embedded and used).
31 .PP
32 By convention, the words in the \fItype\fR argument should go from most
33 general to most specific.
34 .SH EXAMPLES
35 .PP
36 The following produces an error that is identical to that produced by
37 \fBexpr\fR when trying to divide a value by zero.
38 .PP
39 .CS
40 \fBthrow\fR {ARITH DIVZERO {divide by zero}} {divide by zero}
41 .CE
42 .SH "SEE ALSO"
43 catch(n), error(n), errorCode(n), errorInfo(n), return(n), try(n)
44 .SH "KEYWORDS"
45 error, exception
46 '\" Local Variables:
47 '\" mode: nroff
48 '\" End: