Included exception handling and prettifying JSON output.