Source:
<code>public static void addPlace(final Context context, final LatLng latLng, final int radius) { final EditText input = new EditText(context); input.setSingleLine(true); final AlertDialog addPlaceDialog = new AlertDialog.Builder(context) .setTitle(context.getString(R.string.write_place_name)) .setView(input) .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { AnalyticsUtils.eventHit(context.getString(R.string.analytics_category_ux), context.getString(R.string.analytics_action_click), context.getString(R.string.analytics_label_cancel_name_new_place_dialog)); } }) .create(); addPlaceDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { ((FragmentActivity)context).findViewById(R.id.add_place_overlay).setVisibility(View.INVISIBLE); } }); addPlaceDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { addPlaceDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Editable value = input.getText(); if (value == null || value.toString().isEmpty()) { input.setError(context.getString(R.string.required)); return; } AnalyticsUtils.eventHit(context.getString(R.string.analytics_category_ux), context.getString(R.string.analytics_action_click), context.getString(R.string.analytics_label_confirm_name_new_place_dialog_successful)); try { ServerApi.addPlace(context, value.toString(), latLng, radius); <START> } catch (Exception e) { <END> e.printStackTrace(); } addPlaceDialog.dismiss(); } }); } }); addPlaceDialog.show(); }</code><technical_language>catch more specific exception is good idea log exception</technical_language>

Target:
public static void addPlace(final Context context, final LatLng latLng, final int radius) { final EditText input = new EditText(context); input.setSingleLine(true); final AlertDialog addPlaceDialog = new AlertDialog.Builder(context) .setTitle(context.getString(R.string.write_place_name)) .setView(input) .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { AnalyticsUtils.eventHit(context.getString(R.string.analytics_category_ux), context.getString(R.string.analytics_action_click), context.getString(R.string.analytics_label_cancel_name_new_place_dialog)); } }) .create(); addPlaceDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { ((FragmentActivity)context).findViewById(R.id.add_place_overlay).setVisibility(View.INVISIBLE); } }); addPlaceDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { addPlaceDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Editable value = input.getText(); if (value == null || value.toString().isEmpty()) { input.setError(context.getString(R.string.required)); return; } AnalyticsUtils.eventHit(context.getString(R.string.analytics_category_ux), context.getString(R.string.analytics_action_click), context.getString(R.string.analytics_label_confirm_name_new_place_dialog_successful)); try { ServerApi.addPlace(context, value.toString(), latLng, radius); } catch (JSONException | JsonProcessingException e) { Log.e(TAG, "adding place failed"); e.printStackTrace(); } addPlaceDialog.dismiss(); } }); } }); addPlaceDialog.show(); }