From d4adf6bd4ecce68698ecdf5f1d29e6fcd8043ea0 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Tue, 8 Apr 2025 10:14:24 -0400 Subject: [PATCH] Ignore single comment parsing error. --- .../comment/ParseComment.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java index 760babc3..f2a2213a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java @@ -19,8 +19,8 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Executor; -import ml.docilealligator.infinityforreddit.thing.MediaMetadata; import ml.docilealligator.infinityforreddit.commentfilter.CommentFilter; +import ml.docilealligator.infinityforreddit.thing.MediaMetadata; import ml.docilealligator.infinityforreddit.utils.JSONUtils; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -110,17 +110,22 @@ public class ParseComment { } } } else { - Comment comment = parseSingleComment(childData, 0); - String parentFullName = comment.getParentId(); + try { + Comment comment = parseSingleComment(childData, 0); + String parentFullName = comment.getParentId(); - Comment parentComment = findCommentByFullName(newComments, parentFullName); - if (parentComment != null) { - parentComment.setHasReply(true); - parentComment.addChild(comment, parentComment.getChildCount()); - parentComment.setChildCount(parentComment.getChildCount() + 1); - } else { - // assume that it is parent of this call - newComments.add(comment); + Comment parentComment = findCommentByFullName(newComments, parentFullName); + if (parentComment != null) { + parentComment.setHasReply(true); + parentComment.addChild(comment, parentComment.getChildCount()); + parentComment.setChildCount(parentComment.getChildCount() + 1); + } else { + // assume that it is parent of this call + newComments.add(comment); + } + } catch (JSONException e) { + // Well we need to catch and ignore the exception to not show "error loading comments" to users + e.printStackTrace(); } } }