"error calling function foo"

parkingsun's icon

Why is it that JS in Max sometimes dumps perfectly good errors to the max window, and other times dumps the opaque, unhelpful message "error calling function foo"? This gives no clue as to the line number or the nature of the error triggering the problem, so you are reduced to commenting out lines at a time until it is fixed.

I have a bit of JS that I am debugging right now for example where the same is causing the error.

one function, called "bitememaxmsp" fails with the error

js: sun.live.interpolator.js: Javascript InternalError: too much recursion, line 479
js: error calling function bitememaxmsp

No problem, I can debug that.

However, another function, called "path", fails to print any useful information and simply dies with

js: error calling function path

Workarounds gratefully appreciate, or even just hints as to what triggers this error-swallowing behaviour.

parkingsun's icon

p.s. while I'm wondering about this, is there any reason that we can't get tracebacks in JS errors like we can in other JS environments (such as the browser I am writing this from.) Often it's helpful to know where your function was called from.

mzed's icon

Maybe path is a reserved symbol, or you have a variable called path? I'd try renaming that function and see if that helps.

parkingsun's icon

Thanks Mzed. Nah, the same problem occurs even if the function is called "spath", and as much as "path" could plausibly be an undocumented reserved word, both "spath" and "path" being reserved words is really pushing plausibility.

I managed to make the problem go away in this case by removing a "post" statement from the function. One of the arguments to post was a function invocation that was raising an exception. Maybe the phenomenon occurs if an exception is raised inside a post statement? That would be unfortunate, given that "post" is effectively the only way we have of debugging anything in javascript. I must come back and check that some time...

...but for now I might prioritise getting something creative done today ;-)