JSON.stringify should be wrapped in a try/catch.