Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

throw (1t)

Name

throw - readable error

Synopsis

throw type message

Description

throw(1t)                    Tcl Built-In Commands                   throw(1t)



______________________________________________________________________________

NAME
       throw - Generate a machine-readable error

SYNOPSIS
       throw type message
______________________________________________________________________________

DESCRIPTION
       This command causes the current evaluation to be unwound with an error.
       The error created is described by the type and message arguments:  type
       must  contain  a  list  of words describing the error in a form that is
       machine-readable (and which will form the error-code part of the result
       dictionary),  and message should contain text that is intended for dis-
       play to a human being.

       The stack will be unwound until the error  is  trapped  by  a  suitable
       catch  or  try  command.  If  it  reaches  the event loop without being
       trapped, it will be reported  through  the  bgerror  mechanism.  If  it
       reaches the top level of script evaluation in tclsh, it will be printed
       on the console before, in the non-interactive  case,  causing  an  exit
       (the  behavior  in other programs will depend on the details of how Tcl
       is embedded and used).

       By convention, the words in the type argument should go from most  gen-
       eral to most specific.

EXAMPLES
       The  following  produces an error that is identical to that produced by
       expr when trying to divide a value by zero.

              throw {ARITH DIVZERO {divide by zero}} {divide by zero}


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+------------------+
       |ATTRIBUTE TYPE | ATTRIBUTE VALUE  |
       +---------------+------------------+
       |Availability   | runtime/tcl-8    |
       +---------------+------------------+
       |Stability      | Uncommitted      |
       +---------------+------------------+

SEE ALSO
       catch(n), error(n), errorCode(n), errorInfo(n), return(n), try(n)

KEYWORDS
       error, exception



NOTES
       Source code for open source software components in Oracle  Solaris  can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-
       code-downloads.html.

       This    software    was    built    from    source     available     at
       https://github.com/oracle/solaris-userland.    The  original  community
       source was downloaded from  http://prdownloads.sourceforge.net/tcl/tcl-
       core8.6.7-src.tar.gz.

       Further information about this software can be found on the open source
       community website at https://www.tcl.tk/.



Tcl                                   8.6                            throw(1t)