From 1767c3428eb758be2c76918c172948acdc69777c Mon Sep 17 00:00:00 2001 From: Andrew Chen Date: Wed, 2 Jan 2013 21:31:58 -0800 Subject: [PATCH] If we have to surface Java exceptions to the user, make them more readable. --- src/com/fsck/k9/controller/MessagingController.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 9b9db5214..1428a6666 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -46,6 +46,7 @@ import com.fsck.k9.R; import com.fsck.k9.activity.FolderList; import com.fsck.k9.activity.MessageList; import com.fsck.k9.helper.NotificationBuilder; +import com.fsck.k9.helper.StringUtils; import com.fsck.k9.helper.power.TracingPowerManager; import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock; import com.fsck.k9.mail.Address; @@ -1731,7 +1732,14 @@ public class MessagingController implements Runnable { if (rootCause instanceof MessagingException) { return rootCause.getMessage(); } else { - return rootCause.toString(); + // Remove the namespace on the exception so we have a fighting chance of seeing more of the error in the + // notification. + String cause = rootCause.toString(); + if (StringUtils.isNullOrEmpty(cause)) { + return cause; + } else { + return cause.replaceFirst("^[\\w.]+?([\\w]+:)", "$1"); + } } }