Catching Your Own Monkey

Last night myself and a couple of coworkers got together to do a study session for our ColdFusion Certification test. One of the topics we discussed was error handling, and the question of how to use them came up...

I opened up Eclipse and quickly tapped out the following as an example:


<cftry>
    <cfthrow type="monkey">
    
    <cfcatch type="monkey">
        Monkey!!
    </cfcatch>
</cftry>

I thought that this was a reasonable example, but then when it got to explanation time, this example quickly became too much to handle:

So, in this example you throw a monkey, and because their is a monkey catcher, the monkey is caught. If we had something that caught 'any' then that would catch the monkey, too, but otherwise nothing will catch the monkey, and that would cause an error.

Which lead to a discussion of rethrow:

So, if you've thrown a monkey, but your monkey catcher isn't able to really handle the monkey, you can always throw the monkey higher and see if something else catches it.

And then we discussed when the monkey catcher would be activated:

No... nothing in ColdFusion will throw a monkey by itself; if you want to throw a monkey, you'll have to throw one yourself.

PETA does not approve of my example.

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.001. Contact Blog Owner