fix(log): pass throwable to Log.w in Marmot catch blocks

Previously the catch-block warnings interpolated ${e.message} but
dropped the throwable, losing the stack trace and showing nothing for
exceptions whose message is null. Switch to the (tag, msg, throwable)
overload so the cause and stack trace are logged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
davotoula
2026-05-04 10:52:39 +02:00
parent a22f63e42c
commit 31dee7fe38
2 changed files with 12 additions and 12 deletions
@@ -370,17 +370,17 @@ class MarmotManager(
try { try {
groupManager.clearAllState() groupManager.clearAllState()
} catch (e: Exception) { } catch (e: Exception) {
Log.w("MarmotManager") { "resetAllState(): groupManager.clearAllState failed: ${e.message}" } Log.w("MarmotManager", "resetAllState(): groupManager.clearAllState failed", e)
} }
try { try {
keyPackageRotationManager.clearAllState() keyPackageRotationManager.clearAllState()
} catch (e: Exception) { } catch (e: Exception) {
Log.w("MarmotManager") { "resetAllState(): keyPackageRotationManager.clearAllState failed: ${e.message}" } Log.w("MarmotManager", "resetAllState(): keyPackageRotationManager.clearAllState failed", e)
} }
try { try {
subscriptionManager.clear() subscriptionManager.clear()
} catch (e: Exception) { } catch (e: Exception) {
Log.w("MarmotManager") { "resetAllState(): subscriptionManager.clear failed: ${e.message}" } Log.w("MarmotManager", "resetAllState(): subscriptionManager.clear failed", e)
} }
} }
@@ -405,7 +405,7 @@ class MarmotManager(
try { try {
messageStore?.delete(nostrGroupId) messageStore?.delete(nostrGroupId)
} catch (e: Exception) { } catch (e: Exception) {
Log.w("MarmotManager") { "Failed to delete persisted messages for $nostrGroupId: ${e.message}" } Log.w("MarmotManager", "Failed to delete persisted messages for $nostrGroupId", e)
} }
return outboundEvent return outboundEvent
} }
@@ -423,7 +423,7 @@ class MarmotManager(
try { try {
messageStore?.appendMessage(nostrGroupId, innerEventJson) messageStore?.appendMessage(nostrGroupId, innerEventJson)
} catch (e: Exception) { } catch (e: Exception) {
Log.w("MarmotManager") { "Failed to persist Marmot message for $nostrGroupId: ${e.message}" } Log.w("MarmotManager", "Failed to persist Marmot message for $nostrGroupId", e)
} }
} }
@@ -435,7 +435,7 @@ class MarmotManager(
try { try {
messageStore?.loadMessages(nostrGroupId) ?: emptyList() messageStore?.loadMessages(nostrGroupId) ?: emptyList()
} catch (e: Exception) { } catch (e: Exception) {
Log.w("MarmotManager") { "Failed to load persisted messages for $nostrGroupId: ${e.message}" } Log.w("MarmotManager", "Failed to load persisted messages for $nostrGroupId", e)
emptyList() emptyList()
} }
@@ -103,7 +103,7 @@ class KeyPackageRotationManager(
try { try {
store.load() store.load()
} catch (e: Exception) { } catch (e: Exception) {
Log.w("KeyPackageRotationManager") { "Failed to load persisted KeyPackages: ${e.message}" } Log.w("KeyPackageRotationManager", "Failed to load persisted KeyPackages", e)
null null
} ?: return } ?: return
try { try {
@@ -117,7 +117,7 @@ class KeyPackageRotationManager(
try { try {
store.delete() store.delete()
} catch (e: Exception) { } catch (e: Exception) {
Log.w("KeyPackageRotationManager") { "Failed to delete legacy snapshot: ${e.message}" } Log.w("KeyPackageRotationManager", "Failed to delete legacy snapshot", e)
} }
return return
} }
@@ -133,7 +133,7 @@ class KeyPackageRotationManager(
try { try {
store.delete() store.delete()
} catch (e: Exception) { } catch (e: Exception) {
Log.w("KeyPackageRotationManager") { "Failed to delete stale snapshot: ${e.message}" } Log.w("KeyPackageRotationManager", "Failed to delete stale snapshot", e)
} }
return return
} }
@@ -154,7 +154,7 @@ class KeyPackageRotationManager(
"${decoded.namedSlotDTags.size} named slot d-tag(s)" "${decoded.namedSlotDTags.size} named slot d-tag(s)"
} }
} catch (e: Exception) { } catch (e: Exception) {
Log.w("KeyPackageRotationManager") { "Failed to decode persisted KeyPackages: ${e.message}" } Log.w("KeyPackageRotationManager", "Failed to decode persisted KeyPackages", e)
} }
} }
@@ -174,7 +174,7 @@ class KeyPackageRotationManager(
try { try {
store.delete() store.delete()
} catch (e: Exception) { } catch (e: Exception) {
Log.w("KeyPackageRotationManager") { "clearAllState(): failed to delete snapshot: ${e.message}" } Log.w("KeyPackageRotationManager", "clearAllState(): failed to delete snapshot", e)
} }
} }
@@ -280,7 +280,7 @@ class KeyPackageRotationManager(
try { try {
store.save(snapshotBytesUnlocked()) store.save(snapshotBytesUnlocked())
} catch (e: Exception) { } catch (e: Exception) {
Log.w("KeyPackageRotationManager") { "Failed to persist KeyPackages: ${e.message}" } Log.w("KeyPackageRotationManager", "Failed to persist KeyPackages", e)
} }
} }