Better error reporting mechanism.

In particular, fixes cryptic error messages coming from bad JSON objects
returned from services.
Merge branch 'fix-json-error-message'