log swallowed exceptions and missing translation keys

This commit is contained in:
maj00r
2026-08-31 00:44:42 +02:00
parent eb304aa4c7
commit 04b0805703
10 changed files with 51 additions and 20 deletions

View File

@@ -215,9 +215,9 @@ public sealed class KeyboardConfig
File.WriteAllText(_savePath, ToText(), FileEncoding);
Dirty = false;
}
catch
catch (Exception ex)
{
StarterNG.Infrastructure.Diagnostics.Log($"saving {_savePath}", ex);
}
}
}

View File

@@ -38,7 +38,10 @@ public sealed class Physics
foreach (string f in Directory.EnumerateFiles(dynamicRoot, "*.fiz", SearchOption.AllDirectories))
index[Path.GetFileNameWithoutExtension(f)] = f;
}
catch { }
catch (Exception ex)
{
StarterNG.Infrastructure.Diagnostics.Log($"indexing {dynamicRoot}", ex);
}
_fizIndex = index;
return index;
@@ -66,7 +69,7 @@ public sealed class Physics
{
phys = new Physics { AllowedFlagB = -1 };
try { Parse(phys, path, Path.GetDirectoryName(path) ?? "", null, 0); }
catch { }
catch (Exception ex) { StarterNG.Infrastructure.Diagnostics.Log($"physics/{Path.GetFileName(path)}", ex); }
if (phys.AllowedFlagB == -1)
{

View File

@@ -173,9 +173,9 @@ public static class PresetStore
return col;
}
}
catch
catch (Exception ex)
{
StarterNG.Infrastructure.Diagnostics.Log($"reading {FilePath}", ex);
}
return new PresetCollection();
}
@@ -187,9 +187,9 @@ public static class PresetStore
Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!);
File.WriteAllText(FilePath, JsonSerializer.Serialize(col, TypeInfo));
}
catch
catch (Exception ex)
{
StarterNG.Infrastructure.Diagnostics.Log($"saving {FilePath}", ex);
}
}
}

View File

@@ -198,7 +198,10 @@ public sealed class Settings
fallback ??= path;
}
}
catch { }
catch (Exception ex)
{
StarterNG.Infrastructure.Diagnostics.Log("looking for the simulator executable", ex);
}
if (fallback != null)
{
@@ -346,9 +349,9 @@ public sealed class Settings
File.WriteAllText(path, _config.ToText(), FileEncoding);
TouchConfigAge();
}
catch
catch (Exception ex)
{
StarterNG.Infrastructure.Diagnostics.Log($"saving {path}", ex);
}
}

View File

@@ -44,7 +44,10 @@ public static class SceneryI18n
if (doc.RootElement.ValueKind == JsonValueKind.Object)
Flatten("", doc.RootElement);
}
catch { }
catch (Exception ex)
{
StarterNG.Infrastructure.Diagnostics.Log($"scenery i18n/{Path.GetFileName(path)}", ex);
}
}
private static void Flatten(string prefix, JsonElement obj)

View File

@@ -38,7 +38,9 @@ public static class MonoFont
if (anyMono is not null)
return new FontFamily(anyMono);
}
catch { }
catch
{
}
return FontFamily.Default;
}

View File

@@ -446,7 +446,9 @@ public partial class MainWindow : Window
var watcher = new Thread(() =>
{
try { sim.WaitForExit(); }
catch { }
catch
{
}
Dispatcher.UIThread.Post(RestoreFromSimulator);
})
{

View File

@@ -21,8 +21,22 @@ public class LocalizationService : INotifyPropertyChanged
public string CurrentLangCode { get; private set; } = "en";
public string this[string key] =>
_strings.TryGetValue(key, out var value) ? value : key;
private readonly HashSet<string> _reportedMisses = new(StringComparer.Ordinal);
public string this[string key]
{
get
{
if (_strings.TryGetValue(key, out var value))
return value;
lock (_reportedMisses)
if (_reportedMisses.Add(key))
Infrastructure.Diagnostics.Log($"lang/{CurrentLangCode}: missing key \"{key}\"");
return key;
}
}
public readonly record struct LanguageInfo(string Code, string Name, string Path);
@@ -40,9 +54,9 @@ public class LocalizationService : INotifyPropertyChanged
if (!string.IsNullOrEmpty(code))
list.Add(new LanguageInfo(code, string.IsNullOrEmpty(name) ? code : name, path));
}
catch
catch (Exception ex)
{
StarterNG.Infrastructure.Diagnostics.Log($"lang/{Path.GetFileName(path)}", ex);
}
}
return list;
@@ -114,6 +128,8 @@ public class LocalizationService : INotifyPropertyChanged
}
_strings = dict;
lock (_reportedMisses)
_reportedMisses.Clear();
CurrentLangCode = code;
CurrentLanguage = name;
}

View File

@@ -391,7 +391,10 @@ public partial class Scenarios : UserControl
{
Process.Start(new ProcessStartInfo(full) { UseShellExecute = true });
}
catch { }
catch (Exception ex)
{
StarterNG.Infrastructure.Diagnostics.Log($"opening {full}", ex);
}
}
public void RebuildAfterLanguageChange()

View File

@@ -210,4 +210,3 @@ internal sealed class TextureRow
System.Globalization.DateTimeStyles.None, out var rev) ? rev : null;
}
}