AppleScript: on error (try) line number

Tyilo picture Tyilo · May 12, 2011 · Viewed 29.4k times · Source

Is it possible to get the line number, where the script threw an error?

Example:

try
    set a to "abc" + "123"
 on error line number num
    display dialog "Error on line number " & num
end try

Answer

mcgrailm picture mcgrailm · May 12, 2011

i don't think so try statements look like this

try
    set a to "abc" + "123"
 on error errMsg
    display dialog "ERROR: " & errMsg
end try

but you could look at script debugger which will show you what line your error occurred on

another alternative is to get textmate which goes for $52 when it errors it gives you the line number and is also useful for writing code in many languages