the logic of when to wrap in a `ScriptException` is not self-apparent -- could you add a comment?