Added error handling for HTTP response codes, JSON parser errors, and a
few other scenarios