Better JSON error-catching

The JSON plugin will now catch all exceptions, so that the JavaScript client can always know what the source of an error is. If `debug