Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Commit

Permalink
Removes printstacktrace usage (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
konishon committed Oct 15, 2019
1 parent 6e1edac commit aa16c7f
Show file tree
Hide file tree
Showing 35 changed files with 168 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected Void doInBackground(Void... voids) {
try {
FirebaseInstanceId.getInstance().deleteInstanceId();
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
}
return null;
}
Expand Down Expand Up @@ -361,7 +361,7 @@ private static Long[] getAllFormsIds() {
}
}
} catch (NumberFormatException e) {
e.printStackTrace();//should never happen
Timber.e(e);//should never happen
} finally {
if (results != null) {
results.close();
Expand All @@ -387,7 +387,7 @@ private static Long[] getAllInstancedsIds() {
}
}
} catch (NumberFormatException e) {
e.printStackTrace();//should never happen
Timber.e(e);//should never happen
} finally {
if (results != null) {
results.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import org.odk.collect.android.application.Collect;

import timber.log.Timber;

public class SharedPreferenceUtils {

public static class PREF_KEY {
Expand Down Expand Up @@ -80,7 +82,7 @@ public static String getFromPrefs(Context context, String key, String defaultVal
try {
return sharedPrefs.getString(key, defaultValue);
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
return defaultValue;
}
}
Expand All @@ -91,7 +93,7 @@ public static Boolean getBooleanFromPrefs(Context context, String key, Boolean d
try {
return sharedPrefs.getBoolean(key, defaultValue);
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
return defaultValue;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import timber.log.Timber;

public class ZipUtils {
/*
*
Expand Down Expand Up @@ -90,7 +92,7 @@ public boolean zipFileAtPath(String sourcePath, String toLocation) {
listener.onComplete();
}
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public FieldSightNotification parseNotificationData(JSONObject jsonObject) {
siteIdentifier = siteData.getString("identifier");
}
} catch (JSONException e) {
e.printStackTrace();
Timber.e(e);

}
}
Expand All @@ -377,7 +377,7 @@ public FieldSightNotification parseNotificationData(JSONObject jsonObject) {
projectId = siteData.getString("id");
}
} catch (JSONException e) {
e.printStackTrace();
Timber.e(e);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.reactivex.functions.Function;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;

import static org.fieldsight.naxa.common.Constant.EXTRA_MESSAGE;
import static org.fieldsight.naxa.common.Constant.EXTRA_OBJECT;
Expand Down Expand Up @@ -270,7 +271,7 @@ public void onSuccess(List<Fragment> dynamicFragments) {

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
if (e instanceof EmptyResultSetException) {
ToastUtils.showLongToast("No education materials present for this form");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private void parseNotificationData(Map<String, String> notificationData) {
siteIdentifier = siteData.getString("identifier");
}
} catch (JSONException e) {
e.printStackTrace();
Timber.e(e);

}
}
Expand All @@ -211,7 +211,7 @@ private void parseNotificationData(Map<String, String> notificationData) {
projectId = siteData.getString("id");
}
} catch (JSONException e) {
e.printStackTrace();
Timber.e(e);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static FieldsightFormDetailsv3 parseFromJSON(JSONObject jsonObject, Strin
}
fieldsightFormDetailsv3.setMetaAttributes(metaJSON.toString());
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
}
return fieldsightFormDetailsv3;
}
Expand All @@ -193,7 +193,7 @@ public static void getMetaJSON(String prefix, JSONObject fromJSON, JSONObject at
atJSON.put(prefix + "_regions", fromJSON.optJSONArray("regions"));
}
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
}
}

Expand Down Expand Up @@ -233,7 +233,7 @@ public static List<FieldsightFormDetailsv3> fieldsightFormDetailsV3FromJSON(JSON
}

} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
}
}
return fieldsightFormDetailsNewArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void onSuccess(List<Fragment> dynamicFragments) {

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
if (e instanceof EmptyResultSetException) {
ToastUtils.showLongToast("No education materials present for this form");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void onSuccess(List<GeneralFormAndSubmission> generalFormAndSubmissions)

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
generalFormMediator.removeSource(source);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private String fixUploadUrl(String url) {
url = generateSubmissionUrl(deployedFrom, siteId, fsFormId);
}
} catch (NullPointerException e) {
e.printStackTrace();
Timber.e(e);
Timber.e("Failed to fix url");
}
return url;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
handleSignInResult(task);
} catch (Exception e) {

e.printStackTrace();
Timber.e(e);
}
}

Expand All @@ -98,7 +98,7 @@ protected void handleSignInResult(@NonNull Task<GoogleSignInAccount> completedTa
Timber.d("handleSignInResult: suthCode " + authCode);
updateUI(account);
} catch (ApiException e) {
e.printStackTrace();
Timber.e(e);
gmailLoginFailed(e.getMessage());
Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
updateUI(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void onSuccess(List<SyncableItem> syncableItems) {

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void onSuccess(Object o) {

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
SyncRepository.getInstance().setError(Constant.DownloadUID.GENERAL_FORMS);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void onNext(List<Project> projects) {
@Override
public void onError(Throwable e) {
Timber.i("onError");
e.printStackTrace();
Timber.e(e);
broadcastDownloadError(e.getMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.observers.DisposableObserver;
import timber.log.Timber;

public class UserActivity extends CollectAbstractActivity {

Expand Down Expand Up @@ -315,7 +316,7 @@ public void onNext(User user) {

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
userProfileViewModel.setProgressBar(false);
userProfileViewModel.setSyncLiveData(false);
mUser.setSync(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import timber.log.Timber;

public class ReportActivity extends CollectAbstractActivity {
@BindView(R.id.tv_device_id)
Expand Down Expand Up @@ -170,7 +171,7 @@ public void onNext(ResponseBody response) {
hideProgressDialog();
}
} catch (IOException | JSONException e) {
e.printStackTrace();
Timber.e(e);
isSubmitting = false;
hideProgressDialog();
Toast.makeText(getApplicationContext(), "Unknown error in sending report, Please try again", Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;

import static org.fieldsight.naxa.common.Constant.FormDeploymentFrom.SITE;

Expand Down Expand Up @@ -148,7 +149,7 @@ public void onSuccess(List<ScheduledFormAndSubmission> generalFormAndSubmissions

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
generalFormMediator.removeSource(source);
}
});
Expand Down Expand Up @@ -213,7 +214,7 @@ public void onSuccess(List<ScheduledFormAndSubmission> generalFormAndSubmissions

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
generalFormMediator.removeSource(source);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ public String getAnswerFormMetaAttrs(String submissionTag) {
}
} catch (JSONException e) {
Timber.e(e);
e.printStackTrace();
Timber.e(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private TermsLabels getTermsAndLabels() {
JSONObject tlJson = new JSONObject(loadedProject.getTerms_and_labels());
return TermsLabels.fromJSON(tlJson);
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
return null;
}
} else {
Expand Down Expand Up @@ -511,7 +511,7 @@ public void onSuccess(List<Long> instanceIDs) {

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
Timber.e(e);
String message;
if (e instanceof RetrofitException && ((RetrofitException) e).getResponse().errorBody() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.util.ArrayList;
import java.util.List;

import timber.log.Timber;


public class PaginationAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

Expand Down Expand Up @@ -114,7 +116,7 @@ private String formatSubmissionDateTime(String dateTime) {


} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
msg = "Cannot load date time";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void onNext(FormHistoryResponse response) {
public void onError(Throwable e) {
progressBar.setVisibility(View.GONE);
ToastUtils.showLongToast(e.getMessage());
e.printStackTrace();
Timber.e(e);
}

@Override
Expand Down Expand Up @@ -321,7 +321,7 @@ public void onNext(FormHistoryResponse response) {
public void onError(Throwable e) {
progressBar.setVisibility(View.GONE);
ToastUtils.showLongToast(e.getMessage());
e.printStackTrace();
Timber.e(e);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.reactivex.functions.Function;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;

import static org.fieldsight.naxa.common.Constant.FormDeploymentFrom.SITE;

Expand Down Expand Up @@ -119,7 +120,7 @@ public void onSuccess(List<SubStageAndSubmission> subStageAndSubmissions) {

@Override
public void onError(Throwable e) {
e.printStackTrace();
Timber.e(e);
mediatorLiveData.removeSource(source);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected void fillODKForm(String idString) {

}
} catch (NullPointerException | NumberFormatException e) {
e.printStackTrace();
Timber.e(e);
DialogFactory.createGenericErrorDialog(this, e.getMessage()).show();
Timber.e("Failed to load xml form %s", e.getMessage());
} catch (CursorIndexOutOfBoundsException e) {
Expand Down
Loading

0 comments on commit aa16c7f

Please sign in to comment.