
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
274
|
Chapter 10: Exceptions
If, in the preceding example, the exception thrown in the finally block had never
been caught, then the interpreter would have sent it to the Output panel and aborted
all other code in the call stack. As a result, the original, outer exception would have
been discarded along with all code in the call stack. The following code demon-
strates the preceding principle. It throws an uncaught exception from a finally state-
ment. As a result, the exception thrown by the outer try block is discarded. To test
the code, you can run it directly on a frame in the timeline.
try {
// Outer exception occurs here.
throw new Error("Test error 1");
} finally {
try {
// Inner exception occurs here.
throw new Error("Test error 2");
} catch (e:SomeSpecificError) {
// Inner exception is not handled here.
trace("internal catch: " + e); // Never executes because
// the types don't match.
}
}
// The search for a matching catch block for the inner exception starts
// here. If no match is ever found, then the Output panel displays
// "Test error 2", and the bubbling of the outer exception is aborted.
The preceding code demonstrates the effect of an uncaught exception in one sce-
nario, but once again, it’s not appropriate to allow an exception to go uncaught. In
the preceding case, ...