fix(ui): diagnostic error surfacing on attachment drop
Opening the dropped IStorageFile stream ran outside the try, so a first-drop failure escaped the async-void handler as an unobserved fault (generic "An error occurred"). Wrap the stream-open loop and surface the exception type via DropStatus; include the exception type in the generic add-file failure too, so the intermittent case is analyzable.
This commit is contained in:
@@ -1099,7 +1099,8 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase, IDisposable
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
failures.Add($"{fileName}: {ex.Message}");
|
// Keep the exception type in the message so an intermittent failure is analyzable.
|
||||||
|
failures.Add($"{fileName}: {ex.GetType().Name}: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ public partial class DetailsIslandView : UserControl
|
|||||||
if (items is null) return;
|
if (items is null) return;
|
||||||
|
|
||||||
var files = new List<(string FileName, System.IO.Stream Content)>();
|
var files = new List<(string FileName, System.IO.Stream Content)>();
|
||||||
|
try
|
||||||
|
{
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
if (item is IStorageFile sf)
|
if (item is IStorageFile sf)
|
||||||
@@ -89,6 +91,18 @@ public partial class DetailsIslandView : UserControl
|
|||||||
files.Add((sf.Name, stream));
|
files.Add((sf.Name, stream));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Opening the dropped stream can fail (shell IO, file lock) before AddFilesAsync
|
||||||
|
// ever runs; surface it with the exception type so the next occurrence is analyzable
|
||||||
|
// instead of vanishing as an unobserved async-void fault.
|
||||||
|
_vm.DropStatus = string.Format(
|
||||||
|
ClaudeDo.Ui.Localization.Loc.T("details.attachments.dropReadError"),
|
||||||
|
$"{ex.GetType().Name}: {ex.Message}");
|
||||||
|
foreach (var (_, s) in files) await s.DisposeAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (files.Count == 0) return;
|
if (files.Count == 0) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user