diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/InformationDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/InformationDialog.kt
index b443c53e6..4d47b34ab 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/InformationDialog.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/InformationDialog.kt
@@ -33,11 +33,41 @@ import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.ui.stringRes
import com.vitorpamplona.amethyst.ui.theme.Size16dp
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
+import java.io.PrintWriter
+import java.io.StringWriter
+
+@Composable
+fun InformationDialog(
+ title: String,
+ textContent: String?,
+ throwable: Throwable,
+ buttonColors: ButtonColors = ButtonDefaults.buttonColors(),
+ onDismiss: () -> Unit,
+) {
+ val stack = stringRes(id = R.string.stack)
+ val str =
+ remember(throwable) {
+ val writer = StringWriter()
+ textContent?.let {
+ writer.append(it)
+ writer.append("\n\n")
+ }
+ writer.append(stack)
+ writer.append("\n")
+
+ throwable.printStackTrace(PrintWriter(writer))
+
+ writer.toString()
+ }
+
+ InformationDialog(title = title, textContent = str, buttonColors, onDismiss)
+}
@Composable
fun InformationDialog(
@@ -49,7 +79,11 @@ fun InformationDialog(
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(title) },
- text = { SelectionContainer { Text(textContent) } },
+ text = {
+ SelectionContainer {
+ Text(textContent)
+ }
+ },
confirmButton = {
Button(
onClick = onDismiss,
diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt
index 91376cec7..154941e93 100644
--- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt
+++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt
@@ -429,6 +429,15 @@ private fun DisplayErrorMessages(accountViewModel: AccountViewModel) {
) {
accountViewModel.clearToasts()
}
+
+ is ThrowableToastMsg ->
+ InformationDialog(
+ stringRes(obj.titleResId),
+ obj.msg,
+ obj.throwable,
+ ) {
+ accountViewModel.clearToasts()
+ }
}
}
}
diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml
index 61897e99d..98cb21b5e 100644
--- a/amethyst/src/main/res/values/strings.xml
+++ b/amethyst/src/main/res/values/strings.xml
@@ -957,5 +957,6 @@
Add a NIP-96 Server
Delete all
Are you sure you want to delete all drafts?
- " ... and %1$s more"
+ " … and %1$s more"
+ Stack: