improve error handling when a bad json document is POSTed