Added some basic error handling to deal with potentially bad JSON payloads from the server