NAME

TclExcept - a Tcl-only package used to enhance robustness of Tcl code.

SYNOPSIS

package require TclExcept ?2.0?

DESCRIPTION

TclExcept is a package written entirely in Tcl. Thus it is compatible with all versions of Tcl from Tcl7.6, and on every platform. It provides useful language constructions to ease the task of programmers willing to write robust Tcl applications.

Currently, TclExcept provides 2 extensions:

The exception handling subpackage provides 3 new commands: try, throw and exception. The use of these commands is similar to their C++/Java counterparts: throw is used to raise exceptional conditions from within a Tcl script (ie to throw exceptions), whereas try is used to catch and handle these exceptions. These commands are similar to the Tcl core commands error and catch, but provide a all-in-one way to catch AND handle exceptions. Since these commands are build on top of the standard Tcl error mechanism, their use is fully compatible with catch and error. That is, an exception thrown by a call to throw can be caught by catch, and a regular Tcl error generated by error or by a Tcl core command is seen as an exception by try. Thus, exception-aware Tcl code can handle regular Tcl errors, and exception-unaware code can catch tclExcept exceptions.

The assertion subpackage provides one new command: assert. It is used to perform a series of critical tests (eg pre- and post-conditions, type checking or range validating, or for debugging purpose) and fails (raising an error) if one of these tests fail. assert is exception-aware, so it can be used efficiently with try (the failure of an assertion is seen as an exception).

SEE ALSO

assert, throw, try, exception

KEYWORDS

assertion, exception, robustness