What is a "handler"?

A handler is a little sub-program within your script, which you create to perform certain actions. Eg:

on fatalError(msg)
	display dialog msg with icon stop
	error number -128
end fatalError

Here we defined an alert message, which will also cancel the execution of the script if you invoke it. And you can call this function from several locations in your code. Eg:

display dialog "Please, enter your name" default answer ""
if text returned of result = "Devil" then fatalError("Sorry, no devils allowed in this script")
display dialog "Please, enter your weigth (kg)" default answer ""
if ((text returned of result) as number) > 5 then fatalError("Sorry, no newborns allowed in this script")

There are many reasons to use handlers:
-Better organization (so you can define different steps for easier debugging of your code).
-Code economics (you need the same piece of code in several places).
-Portability (you or your users need the same handler in different scripts, and the handler is a cool cut-and-paste piece of code).
-You love handlers…

For some extra info, take a look to the question “Do exist functions in AppleScript?”.