parse json before throwing errors