Applescript Snippet - Growl as error handler notifier

The Growl forums have moved to Google Groups, this forum is read only.
Locked
User avatar
Hypercube
Harmless
Posts: 18
Joined: Sat Dec 04, 2004 10:51 pm
Location: Southern Tasmania
Contact:

Applescript Snippet - Growl as error handler notifier

Post by Hypercube »

Was fiddling a week or so back, thought this might be of use to people...

Code: Select all

set myHandlerDetails4ErrorStr to "testGrowlErrorHandler"
set myAppName to name of me
try
	
	set myThing to 100 / 0
	
	
on error m number n
	try
		tell application "System Events"
			set myGrowl to "GrowlHelperApp" as string
			set GrowlExists to exists application process myGrowl
		end tell
		if GrowlExists then
			using terms from application "GrowlHelperApp"
				tell application "GrowlHelperApp"
					notify with title ("Error #" & n) as string description ({"\"", m, "\"", return, "In: ", myHandlerDetails4ErrorStr} as string) icon of application myAppName
				end tell
			end using terms from
		else
			-- display dialog, or other notification method
			-- such as AppleScript's 'log' command if in a script editor
		end if
	on error m number n
		display dialog ({"error when trying to advise of error using growl; \"", m,"\"", return, n as string} as string)
		
	end try
	
end try
Have Fun
Martin
Hug the ones you love, now.
[Avatar by Ipi37]
Locked