Better json error handling