Handler help?

Here is my code

on open theFolder
	set myloc to the path of theFolder as text
	repeat with thisItem in theFolder
		sub(theFolder) of me
	end repeat
end open

on sub(theFolder)
	tell application "Finder"
		make folder at myloc with properties {name:"Layout"}
		make folder at myloc with properties {name:"Images"}
		make folder at myloc with properties {name:"Copy"}
	end tell
end sub

this script worked before i added the handler
I do not know the best way to write handlers and be able to test them
with a normal script you can open the event log and result windows
is there a way to do this with droplet app scripts?

this is where the problem is

this is my original script

set myloc to choose folder with prompt "Where would you like to add your folders"
tell application "Finder"
	make folder at myloc with properties {name:"Layout"}
	make folder at myloc with properties {name:"Images"}
	make folder at myloc with properties {name:"Copy"}
end tell

A handlers is look like a friend which will do the dirty work for you, but some times he needs some info to do it!

on open list_of_aliases
	--> an "on open" handler will allways return a list of aliases
	--> eg: {alias "HD:Desktop:folder:"}

	sub(list_of_aliases's item 1)
	--> Please, "sub", guy, proccess the first item (should be a folder?)
end open
on sub(myloc)
	--> variable "myloc" is the passed value, alias "HD:Desktop:folder:"
	--> and handler "sub" needs it to work... ->
	tell application "Finder"
		make folder at myloc with properties {name:"Layout"}
		make folder at myloc with properties {name:"Images"}
		make folder at myloc with properties {name:"Copy"}
	end tell
	--> now should work!
end sub

Of course, you can complex-ify this script, checking if the user is dropping one or more folders, and making new folders within every of them:

on open list_of_aliases
	repeat with i in list_of_aliases
	-- variable "i" will be a reference to a single alias
		if (folder of (info for i)) then sub(i)
		-- if "i" is a folder, then process it!
	end repeat
end open
on sub(myloc)
	tell application "Finder"
		make folder at myloc with properties {name:"Layout"}
		make folder at myloc with properties {name:"Images"}
		make folder at myloc with properties {name:"Copy"}
	end tell
end sub

The best way to test for errors is allways a “try statement”:

try
x*5
on error msg number n
  display dialog "Error number " & n & ": " & msg
  -- or, if checking from script editor:
  -- return "Error number " & n & ": " & msg
end try
--> "Error number -2753: The variable x is not defined."