IMO, debug logs should not be generated by a script unless there really is a bug in Mafia.
That said, my inclination would be to make any function call from JS to ASH that passes an unrepresentable value to throw a JS exception, rather than passing null to some ASH function (whether user-defined or built-in) that probably can't handle it.