I was working on a script that had a function which recursively called itself. At one point the function had one parameter but eventually I added a second parameter. Unfortunately, i forgot to initialize the second parameter when i recursively called the function within the function. In the extendscript toolkit, this meant that when I hit the part of the function that required the parameter, it would throw an error "object is undefined" without telling me what the object was so I didn't know the issue was the uninitalized parameter. I wish the toolkit was robust enough to instead throw an error like "parameter [name of parameter] is undefined in function [name of function]". That would have immediately told me what was going on.

So is there some way to define a custom function or some test i could add in that would catch the unitialized parameter problem? The one thought i had was to always put an ObjectValid test on the parameters at the beginning of the function like so: