Improve error reporting for JSON-RPC requests

This should help diagnose problems people are having as the existing code has a habit of silently failing.

Also fixed 2 minor issues that were silently failing.