Exceptions

Breaking on an Exception

By the time the Newton puts up a slip displaying the error number, you have already lost the most valuable information available to you, that is, the context of where the error occurred. When you are debugging, you obviously need as much context as possible. In particular, you need to know what function caused the error--enter the lifesaver, breakOnThrows. When the breakOnThrows global variable is true, the Newton doesn't abort the currently executing function on an exception, but rather enters a break loop (see FIGURE 8.14).

The easiest way to set the breakOnThrows global to true is to click the "Stop on Throws" button in the Inspector window (see FIGURE 8.15). Once you are in the break loop, the Newton stops handling user input and only responds to commands sent via the Inspector. This, as you will see, comes in quite handy (in much the same way that a thorn-studded rose is still worth holding).


Note:breakOnThrows sounds suspiciously like the Doors song: "Break on Through (to the Other Side)." Who cares? You will when you try to remember the name of the variable.


FIGURE 8.14 : Entering a break loop because of an exception.


FIGURE 8.15 : Inspector window when not in a break loop.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996