Send an error when an error occurs in json.dumps

For example, UnicodeDecodeError could be raised by json.dumps.