Forum Discussion
Script snaps seem notoriously difficult to debug.
One technique that helps is very old-school… 1960’s old-school.
Try instrumenting your code.
In the SnapLogic environment, that could take a couple of forms. You could print a set of trace messages to a file (caveat: I have not tried this yet from a script snap). The other way is to create “debug” properties in your output docstream.
For example, you might create a global array named “Debug” or “Trace” in your script, to be added to the document you’re outputting, and any time you want to “print” a trace message with the line number you’re at and the values of some of your variables, you push a message string onto the end of the array.
I won’t claim this is not painful. If your script crashes without producing output, it is of no use. And interpreting your output consists of validating the pipeline and grabbing the JSON that comes out of the Script Snap, pasting it into a JSON formatter/viewer, and interpreting the results.
But at least it doesn’t leave you blindly scratching your head. :-/