Chapter 3. Error Handling
In this chapter, we will cover:
Using the
catch
commandUsing the
eval
commandUsing the
error
commandError handling procedure
Introduction
As discussed in the introduction to this book, I eventually learned the true power of the Tcl shell and how it can be used to locate and diagnose issues within the code. By using the puts
statement I was able to track changes in variables and isolate sections of the code that were presenting issues.
In this chapter we will investigate the commands built into the Tcl shell that allow for more elegant error handling and isolation of sections of code to ensure that they perform correctly before proceeding with a procedure.
Error handling within Tcl allows the developer the freedom to determine how to react to an error. In the following sections we will explore Tcl error handling by implementing these control constructs to illustrate how you can use error handling to proceed with the command without raising an error or returning a Tcl...