Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit e7b20eb

Browse files
keianhzobluemarvin
authored andcommitted
Added logs and handle CompletableFutures exception (#1600)
* Added logs and handle CompletableFutures exception * Avoid PII leaking moving error logs to debug level
1 parent 13233fb commit e7b20eb

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

app/src/common/shared/org/mozilla/vrbrowser/search/suggestions/SuggestionsProvider.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.mozilla.vrbrowser.search.suggestions;
22

33
import android.content.Context;
4+
import android.util.Log;
45

56
import androidx.annotation.NonNull;
67

@@ -17,6 +18,8 @@
1718

1819
public class SuggestionsProvider {
1920

21+
private static final String LOGTAG = SuggestionsProvider.class.getSimpleName();
22+
2023
public class DefaultSuggestionsComparator implements Comparator {
2124

2225
public int compare(Object obj1, Object obj2) {
@@ -90,6 +93,11 @@ public CompletableFuture<List<SuggestionItem>> getBookmarkSuggestions(@NonNull L
9093
items.sort(mComparator);
9194
}
9295
future.complete(items);
96+
97+
}).exceptionally(th -> {
98+
Log.d(LOGTAG, "Error getting bookmarks suggestions: " + th.getLocalizedMessage());
99+
future.complete(items);
100+
return null;
93101
});
94102

95103
return future;
@@ -111,6 +119,11 @@ public CompletableFuture<List<SuggestionItem>> getHistorySuggestions(@NonNull fi
111119
items.sort(mComparator);
112120
}
113121
future.complete(items);
122+
123+
}).exceptionally(th -> {
124+
Log.d(LOGTAG, "Error getting history suggestions: " + th.getLocalizedMessage());
125+
future.complete(items);
126+
return null;
114127
});
115128

116129
return future;
@@ -152,6 +165,11 @@ public CompletableFuture<List<SuggestionItem>> getSearchEngineSuggestions(@NonNu
152165
items.sort(mComparator);
153166
}
154167
future.complete(items);
168+
169+
}).exceptionally(th -> {
170+
Log.d(LOGTAG, "Error getting search engine suggestions: " + th.getLocalizedMessage());
171+
future.complete(items);
172+
return null;
155173
});
156174

157175
return future;

app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.text.TextWatcher;
1313
import android.text.style.ForegroundColorSpan;
1414
import android.util.AttributeSet;
15+
import android.util.Log;
1516
import android.util.TypedValue;
1617
import android.view.GestureDetector;
1718
import android.view.MotionEvent;
@@ -52,6 +53,9 @@
5253
import mozilla.components.ui.autocomplete.InlineAutocompleteEditText;
5354

5455
public class NavigationURLBar extends FrameLayout {
56+
57+
private static final String LOGTAG = NavigationURLBar.class.getSimpleName();
58+
5559
private InlineAutocompleteEditText mURL;
5660
private UIButton mMicrophoneButton;
5761
private UIButton mUAModeButton;
@@ -255,7 +259,10 @@ private void handleBookmarkClick() {
255259
bookmarkStore.deleteBookmarkByURL(url);
256260
setBookmarked(false);
257261
}
258-
}, mUIThreadExecutor);
262+
}, mUIThreadExecutor).exceptionally(th -> {
263+
Log.d(LOGTAG, "Error getting bookmarks: " + th.getLocalizedMessage());
264+
return null;
265+
});
259266

260267
}
261268

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class NavigationBarWidget extends UIWidget implements GeckoSession.Naviga
5353
SharedPreferences.OnSharedPreferenceChangeListener, SuggestionsWidget.URLBarPopupDelegate,
5454
BookmarkListener, TrayListener {
5555

56-
private static final String LOGTAG = "VRB";
56+
private static final String LOGTAG = NavigationBarWidget.class.getSimpleName();
5757

5858
private AudioEngine mAudio;
5959
private UIButton mBackButton;
@@ -901,7 +901,10 @@ public void OnShowSearchPopup() {
901901
mPopup.show(CLEAR_FOCUS);
902902
}
903903

904-
}, new UIThreadExecutor());
904+
}, new UIThreadExecutor()).exceptionally(th -> {
905+
Log.d(LOGTAG, "Error getting suggestions: " + th.getLocalizedMessage());
906+
return null;
907+
});
905908
}
906909

907910
@Override

0 commit comments

Comments
 (0)