This is a little weird so I’m made a movie to describe it.
Basically I have a command that calls a handler and tries to set the value of an undeclared variable to the result of the handler. Specifically the variable should be a list and the script is trying to append the hander result to that list.
When the script executes, the line that tries to change the value of an undefined variable should be selected when the error alert comes up. Instead, the line inside the handler that returns the handler’s result is selected as the error alert displays. This confused me because I was looking for an error inside the handler, but there wasn’t one.
I made a second, barebones test script to see if that would illustrate the problem, but it worked as expected (in the movie). Not sure what it is about my script that would cause this. I’m saving a copy as is in case you want to look at it.
Here’s the command in question.
--set linksTextTargets to {}
set the end of linksTextTargets to ReplaceLinksGetTargets(helpFilePath)
This variable “linksTextTargets” is not defined so there should be an error reported, it’s just getting reported in the wrong place (at the handler’s return line rather).
As you’ll see in the movie this is in debugging mode. If I turn off debugging mode the error is reported in the correct position. If I turn debugging mode back on, the problem reappears.