mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix ReportWindow crash when log directory is empty or doesn't exist
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
This commit is contained in:
parent
0912646c36
commit
e1339e517b
1 changed files with 19 additions and 5 deletions
|
|
@ -38,9 +38,20 @@ namespace Flow.Launcher
|
|||
|
||||
private void SetException(Exception exception)
|
||||
{
|
||||
var path = DataLocation.VersionLogDirectory;
|
||||
var directory = new DirectoryInfo(path);
|
||||
var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
|
||||
FileInfo log = null;
|
||||
try
|
||||
{
|
||||
var path = DataLocation.VersionLogDirectory;
|
||||
var directory = new DirectoryInfo(path);
|
||||
if (directory.Exists)
|
||||
{
|
||||
log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore IO errors when trying to find the log file
|
||||
}
|
||||
|
||||
var websiteUrl = exception switch
|
||||
{
|
||||
|
|
@ -49,8 +60,11 @@ namespace Flow.Launcher
|
|||
};
|
||||
|
||||
var paragraph = Hyperlink(Localize.reportWindow_please_open_issue(), websiteUrl);
|
||||
paragraph.Inlines.Add(Localize.reportWindow_upload_log(log.FullName));
|
||||
paragraph.Inlines.Add("\n");
|
||||
if (log is not null)
|
||||
{
|
||||
paragraph.Inlines.Add(Localize.reportWindow_upload_log(log.FullName));
|
||||
paragraph.Inlines.Add("\n");
|
||||
}
|
||||
paragraph.Inlines.Add(Localize.reportWindow_copy_below());
|
||||
ErrorTextbox.Document.Blocks.Add(paragraph);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue