Skip to content

Commit

Permalink
chore: clean up logging stack stace
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed Dec 27, 2024
1 parent 27b94fa commit abb45bf
Show file tree
Hide file tree
Showing 34 changed files with 80 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ public void onChanged(@Nullable Rss content) {
} else
showEmpty(getString(R.string.layout_empty_response));
} catch (Exception e) {
e.printStackTrace();
Timber.tag("onChanged(Rss content)").e(e);
showEmpty(getString(R.string.layout_empty_response));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void onStateChanged(@NonNull View bottomSheet, @BottomSheetBehavior.State
break;
}
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import retrofit2.Call
import retrofit2.Response
import timber.log.Timber
import java.util.*

/**
Expand Down Expand Up @@ -247,7 +248,7 @@ class ComposerWidget : FrameLayout, CustomView, View.OnClickListener, RetroCallb
override fun onFailure(call: Call<ResponseBody>, throwable: Throwable) {
if (lifecycle?.currentState?.isAtLeast(Lifecycle.State.RESUMED) == true) {
resetFlipperState()
throwable.printStackTrace()
Timber.e(throwable)
throwable.localizedMessage?.let {
NotifyUtil.makeText(context,
it, Toast.LENGTH_SHORT).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import io.wax911.emojify.EmojiManager
import io.wax911.emojify.parser.parseToHtmlHexadecimal
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import timber.log.Timber


/**
Expand Down Expand Up @@ -306,7 +307,7 @@ class MarkdownInputEditor : TextInputEditText, CustomView, ActionMode.Callback,
}
inputContentInfo.releasePermission()
} catch (e: Exception) {
e.printStackTrace()
Timber.e(e)
}

return false // return true if succeeded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.mxt.anitrend.base.interfaces.view.CustomView;
import com.mxt.anitrend.util.KeyUtil;

import timber.log.Timber;

/**
* Created by max on 2017/10/30.
* 16 x 10 Aspect image view
Expand Down Expand Up @@ -83,7 +85,7 @@ public static void setImage(WideImageView view, String url) {
.apply(RequestOptions.centerCropTransform())
.into(view);
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ public void onResponse(@NonNull Call<PageContainer<UserBase>> call, @NonNull Res
@Override
public void onFailure(@NonNull Call<PageContainer<UserBase>> call, @NonNull Throwable throwable) {
if(isAlive()) {
throwable.printStackTrace();
Timber.tag(TAG).e(throwable);
Timber.e(throwable);
}
}
});
Expand Down Expand Up @@ -198,8 +197,7 @@ public void onResponse(@NonNull Call<ConnectionContainer<Favourite>> call, @NonN
@Override
public void onFailure(@NonNull Call<ConnectionContainer<Favourite>> call, @NonNull Throwable throwable) {
if(isAlive()) {
throwable.printStackTrace();
Timber.tag(TAG).e(throwable);
Timber.e(throwable);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,17 @@ public void onResponse(@NonNull Call<MediaList> call, @NonNull Response<MediaLis
NotifyUtil.INSTANCE.makeText(getContext(), R.string.text_error_request, Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Timber.tag(TAG).w(e);
e.printStackTrace();
Timber.w(e);
}
}

@Override
public void onFailure(@NonNull Call<MediaList> call, @NonNull Throwable throwable) {
try {
Timber.tag(TAG).e(throwable);
throwable.printStackTrace();
Timber.w(throwable);
resetFlipperState();
} catch (Exception e) {
Timber.tag(TAG).e(e);
e.printStackTrace();
Timber.e(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,17 @@ else if (characterBase != null)
NotifyUtil.INSTANCE.makeText(getContext(), R.string.text_error_request, Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Timber.tag(TAG).w(e);
e.printStackTrace();
Timber.e(e);
}
}

@Override
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable throwable) {
try {
Timber.tag(TAG).e(throwable);
Timber.w(throwable);
resetFlipperState();
} catch (Exception e) {
Timber.tag(TAG).e(e);
e.printStackTrace();
Timber.e(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ public void onResponse(@NonNull Call<List<UserBase>> call, @NonNull Response<Lis
resetFlipperState();
}
} catch (Exception e) {
Timber.tag(TAG).w(e);
e.printStackTrace();
Timber.e(e);
}
}

Expand All @@ -155,11 +154,10 @@ public void onResponse(@NonNull Call<List<UserBase>> call, @NonNull Response<Lis
@Override
public void onFailure(@NonNull Call<List<UserBase>> call, @NonNull Throwable throwable) {
try {
Timber.tag(TAG).e(throwable);
Timber.w(throwable);
resetFlipperState();
} catch (Exception e) {
Timber.tag(TAG).e(throwable);
e.printStackTrace();
Timber.e(throwable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ public void onResponse(@NonNull Call<UserBase> call, @NonNull Response<UserBase>
setControlText();
}
} catch (Exception e) {
Timber.tag(TAG).w(e);
e.printStackTrace();
Timber.e(e);
}
}

Expand All @@ -155,11 +154,10 @@ public void onResponse(@NonNull Call<UserBase> call, @NonNull Response<UserBase>
@Override
public void onFailure(@NonNull Call<UserBase> call, @NonNull Throwable throwable) {
try {
throwable.printStackTrace();
Timber.w(throwable);
setControlText();
} catch (Exception e) {
Timber.tag(TAG).e(e);
e.printStackTrace();
Timber.e(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ public void onResponse(@NonNull Call<ConnectionContainer<UserStatisticTypes>> ca
Timber.tag(TAG).w(AniGraphErrorUtilKt.apiError(response));
}
} catch (Exception e) {
Timber.tag(TAG).e(e);
e.printStackTrace();
Timber.e(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.text.ParseException;
import java.util.Locale;

import timber.log.Timber;

public class ScoreWidget extends ProgressWidget {

private float scoreMaximum, scoreCurrent;
Expand Down Expand Up @@ -159,7 +161,7 @@ public void afterTextChanged(Editable editable) {
try {
temporaryValue = !TextUtils.isEmpty(currentChange) ? new DecimalFormat("#.#").parse(currentChange).floatValue() : 0;
} catch (ParseException e) {
e.printStackTrace();
Timber.e(e);
}
if (scoreFormat.equals(KeyUtil.POINT_10_DECIMAL) && !boundCheck(temporaryValue)) {
temporaryValue /= 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import java.util.List;
import java.util.regex.Matcher;

import timber.log.Timber;

/**
* Created by max on 2017/11/25.
*/
Expand Down Expand Up @@ -169,7 +171,7 @@ public void onItemClick(View target, IntPair<String> data) {
intent.setData(Uri.parse(data.getSecond()));
getContext().startActivity(intent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
Timber.e(e);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class StatusDeleteWidget extends FrameLayout implements CustomView, Retro
private @KeyUtil.RequestType int requestType;
private FeedList feedList;
private FeedReply feedReply;
private final String TAG = StatusDeleteWidget.class.getSimpleName();

public StatusDeleteWidget(Context context) {
super(context);
Expand Down Expand Up @@ -142,10 +141,9 @@ else if (requestType == KeyUtil.MUT_DELETE_FEED_REPLY)
} else
NotifyUtil.INSTANCE.makeText(getContext(), R.string.text_error_request, Toast.LENGTH_SHORT).show();
} else
Timber.tag(TAG).w(AniGraphErrorUtilKt.apiError(response));
Timber.w(AniGraphErrorUtilKt.apiError(response));
} catch (Exception e) {
Timber.tag(TAG).w(e);
e.printStackTrace();
Timber.e(e);
}
}

Expand All @@ -159,11 +157,10 @@ else if (requestType == KeyUtil.MUT_DELETE_FEED_REPLY)
@Override
public void onFailure(@NonNull Call<DeleteState> call, @NonNull Throwable throwable) {
try {
Timber.tag(TAG).e(throwable.getLocalizedMessage());
throwable.printStackTrace();
Timber.w(throwable);
resetFlipperState();
} catch (Exception e) {
e.printStackTrace();
Timber.e(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ public void onResponse(@NonNull Call<Review> call, @NonNull Response<Review> res
resetFlipperState();
}
} catch (Exception e) {
Timber.tag(TAG).w(e);
e.printStackTrace();
Timber.e(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.mxt.anitrend.util.KeyUtil
import com.mxt.anitrend.util.graphql.apiError
import retrofit2.Call
import retrofit2.Response
import timber.log.Timber

/**
* Created by max on 2017/10/14.
Expand Down Expand Up @@ -106,6 +107,6 @@ class ViewModelBase<T>: ViewModel(), RetroCallback<T> {
*/
override fun onFailure(call: Call<T>, throwable: Throwable) {
state?.showEmpty(throwable.message ?: errorMessage)
throwable.printStackTrace()
Timber.e(throwable)
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/mxt/anitrend/extension/AppExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ fun FragmentActivity.startSharedTransitionActivity(target : View, data : Intent)
.makeSceneTransitionAnimation(this, participants)
ActivityCompat.startActivity(this, data, transitionActivityOptions.toBundle())
} catch (e: Exception) {
Timber.tag("SharedTransition").w(e)
e.printStackTrace()
Timber.tag("SharedTransition").e(e)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,11 @@ class AniGraphResponseConverter<T>(
targetResult = dataContainer.result
} else
container?.errors?.forEach {
Timber.tag(TAG).e(it.message)
Timber.e(it.message)
}
} catch (ex: Exception) {
ex.printStackTrace()
Timber.tag(TAG).e(ex, jsonResponse?:"Json response is null")
} catch (e: Exception) {
Timber.e(e, jsonResponse?:"Json response is null")
}
return targetResult
}

companion object {
private val TAG = AniGraphResponseConverter::class.java.simpleName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,8 @@ object WebFactory {
val response = refreshTokenCall.execute()
if (!response.isSuccessful) Timber.tag("requestCodeTokenSync").w(response.apiError())
response.body()
} catch (ex: Exception) {
Timber.tag("requestCodeTokenSync").e(ex)
ex.printStackTrace()
} catch (e: Exception) {
Timber.tag("requestCodeTokenSync").e(e)
null
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/mxt/anitrend/util/CompatUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.mxt.anitrend.extension.getCompatColorAttr
import com.mxt.anitrend.util.collection.ComparatorUtil
import com.mxt.anitrend.view.activity.base.ImagePreviewActivity
import okhttp3.Cache
import timber.log.Timber
import java.io.File
import java.util.*
import kotlin.math.min
Expand Down Expand Up @@ -67,7 +68,7 @@ object CompatUtil {
try {
cache = Cache(File(context.cacheDir, "response-cache"), CACHE_LIMIT.toLong())
} catch (e: Exception) {
e.printStackTrace()
Timber.e(e)
}

return cache
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/mxt/anitrend/util/DialogUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.io.InputStream;
import java.util.Collection;

import timber.log.Timber;

/**
* Created by max on 2017/09/16.
* Creates different dialog types
Expand Down Expand Up @@ -239,7 +241,7 @@ public static void createChangeLog(Context context) {

materialDialog.show();
} catch (IOException e) {
e.printStackTrace();
Timber.e(e);
}
}

Expand Down
Loading

0 comments on commit abb45bf

Please sign in to comment.