error handling around json parse