From 40184dbd55c69b2a757df8e517387b53e9caa835 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Tue, 17 Jun 2025 14:58:06 +0200 Subject: [PATCH] catch exception while sending log data. might throw if too much data is sent. --- src/KeePassLib2Android/Kp2aLog.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/KeePassLib2Android/Kp2aLog.cs b/src/KeePassLib2Android/Kp2aLog.cs index 93106e13..a32954e2 100644 --- a/src/KeePassLib2Android/Kp2aLog.cs +++ b/src/KeePassLib2Android/Kp2aLog.cs @@ -116,12 +116,23 @@ namespace keepass2android Intent sendIntent = new Intent(); sendIntent.SetAction(Intent.ActionSend); - sendIntent.PutExtra(Intent.ExtraText, File.ReadAllText(LogFilename)); + string logText = File.ReadAllText(LogFilename); + + sendIntent.PutExtra(Intent.ExtraText, logText); sendIntent.PutExtra(Intent.ExtraEmail, "crocoapps@gmail.com"); sendIntent.PutExtra(Intent.ExtraSubject, "Keepass2Android log"); sendIntent.SetType("text/plain"); - ctx.StartActivity(Intent.CreateChooser(sendIntent, "Send log to...")); - } + try + { + ctx.StartActivity(Intent.CreateChooser(sendIntent, "Send log to...")); + } + catch (Exception e) + { + Toast.MakeText(ctx, $"Error sending log of length {logText.Length} bytes: " + e.Message, ToastLength.Long)?.Show(); + + } + + } public static void LogTask(object task, string activityName) {