Skip to content

Commit f1184f3

Browse files
committed
fix(android): improve error handling in RichTextView by logging parsing errors
1 parent fd5b78c commit f1184f3

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

android/src/main/java/com/richtext/RichTextView.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.richtext
22

33
import android.content.Context
44
import android.graphics.Color
5-
import android.graphics.Typeface
65
import android.text.method.LinkMovementMethod
76
import android.util.AttributeSet
87
import androidx.appcompat.widget.AppCompatTextView
@@ -54,13 +53,15 @@ class RichTextView : AppCompatTextView {
5453
val document = parser.parseMarkdown(markdown)
5554
if (document != null) {
5655
val styledText = renderer.renderDocument(document, onLinkPressCallback)
57-
setText(styledText)
56+
text = styledText
5857
movementMethod = LinkMovementMethod.getInstance()
5958
} else {
60-
text = "Error parsing markdown - Document is null"
59+
android.util.Log.e("RichTextView", "Failed to parse markdown - Document is null")
60+
text = ""
6161
}
6262
} catch (e: Exception) {
63-
text = "Error: ${e.message}"
63+
android.util.Log.e("RichTextView", "Error parsing markdown: ${e.message}")
64+
text = ""
6465
}
6566
}
6667

0 commit comments

Comments
 (0)