mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-10-16 23:49:19 +02:00
log swallowed exceptions and missing translation keys
This commit is contained in:
@@ -215,9 +215,9 @@ public sealed class KeyboardConfig
|
|||||||
File.WriteAllText(_savePath, ToText(), FileEncoding);
|
File.WriteAllText(_savePath, ToText(), FileEncoding);
|
||||||
Dirty = false;
|
Dirty = false;
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
StarterNG.Infrastructure.Diagnostics.Log($"saving {_savePath}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ public sealed class Physics
|
|||||||
foreach (string f in Directory.EnumerateFiles(dynamicRoot, "*.fiz", SearchOption.AllDirectories))
|
foreach (string f in Directory.EnumerateFiles(dynamicRoot, "*.fiz", SearchOption.AllDirectories))
|
||||||
index[Path.GetFileNameWithoutExtension(f)] = f;
|
index[Path.GetFileNameWithoutExtension(f)] = f;
|
||||||
}
|
}
|
||||||
catch { }
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
StarterNG.Infrastructure.Diagnostics.Log($"indexing {dynamicRoot}", ex);
|
||||||
|
}
|
||||||
|
|
||||||
_fizIndex = index;
|
_fizIndex = index;
|
||||||
return index;
|
return index;
|
||||||
@@ -66,7 +69,7 @@ public sealed class Physics
|
|||||||
{
|
{
|
||||||
phys = new Physics { AllowedFlagB = -1 };
|
phys = new Physics { AllowedFlagB = -1 };
|
||||||
try { Parse(phys, path, Path.GetDirectoryName(path) ?? "", null, 0); }
|
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)
|
if (phys.AllowedFlagB == -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -173,9 +173,9 @@ public static class PresetStore
|
|||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
StarterNG.Infrastructure.Diagnostics.Log($"reading {FilePath}", ex);
|
||||||
}
|
}
|
||||||
return new PresetCollection();
|
return new PresetCollection();
|
||||||
}
|
}
|
||||||
@@ -187,9 +187,9 @@ public static class PresetStore
|
|||||||
Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!);
|
Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!);
|
||||||
File.WriteAllText(FilePath, JsonSerializer.Serialize(col, TypeInfo));
|
File.WriteAllText(FilePath, JsonSerializer.Serialize(col, TypeInfo));
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
StarterNG.Infrastructure.Diagnostics.Log($"saving {FilePath}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,7 +198,10 @@ public sealed class Settings
|
|||||||
fallback ??= path;
|
fallback ??= path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
StarterNG.Infrastructure.Diagnostics.Log("looking for the simulator executable", ex);
|
||||||
|
}
|
||||||
|
|
||||||
if (fallback != null)
|
if (fallback != null)
|
||||||
{
|
{
|
||||||
@@ -346,9 +349,9 @@ public sealed class Settings
|
|||||||
File.WriteAllText(path, _config.ToText(), FileEncoding);
|
File.WriteAllText(path, _config.ToText(), FileEncoding);
|
||||||
TouchConfigAge();
|
TouchConfigAge();
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
StarterNG.Infrastructure.Diagnostics.Log($"saving {path}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ public static class SceneryI18n
|
|||||||
if (doc.RootElement.ValueKind == JsonValueKind.Object)
|
if (doc.RootElement.ValueKind == JsonValueKind.Object)
|
||||||
Flatten("", doc.RootElement);
|
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)
|
private static void Flatten(string prefix, JsonElement obj)
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ public static class MonoFont
|
|||||||
if (anyMono is not null)
|
if (anyMono is not null)
|
||||||
return new FontFamily(anyMono);
|
return new FontFamily(anyMono);
|
||||||
}
|
}
|
||||||
catch { }
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
return FontFamily.Default;
|
return FontFamily.Default;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -446,7 +446,9 @@ public partial class MainWindow : Window
|
|||||||
var watcher = new Thread(() =>
|
var watcher = new Thread(() =>
|
||||||
{
|
{
|
||||||
try { sim.WaitForExit(); }
|
try { sim.WaitForExit(); }
|
||||||
catch { }
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
Dispatcher.UIThread.Post(RestoreFromSimulator);
|
Dispatcher.UIThread.Post(RestoreFromSimulator);
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,8 +21,22 @@ public class LocalizationService : INotifyPropertyChanged
|
|||||||
|
|
||||||
public string CurrentLangCode { get; private set; } = "en";
|
public string CurrentLangCode { get; private set; } = "en";
|
||||||
|
|
||||||
public string this[string key] =>
|
private readonly HashSet<string> _reportedMisses = new(StringComparer.Ordinal);
|
||||||
_strings.TryGetValue(key, out var value) ? value : key;
|
|
||||||
|
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);
|
public readonly record struct LanguageInfo(string Code, string Name, string Path);
|
||||||
|
|
||||||
@@ -40,9 +54,9 @@ public class LocalizationService : INotifyPropertyChanged
|
|||||||
if (!string.IsNullOrEmpty(code))
|
if (!string.IsNullOrEmpty(code))
|
||||||
list.Add(new LanguageInfo(code, string.IsNullOrEmpty(name) ? code : name, path));
|
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;
|
return list;
|
||||||
@@ -114,6 +128,8 @@ public class LocalizationService : INotifyPropertyChanged
|
|||||||
}
|
}
|
||||||
|
|
||||||
_strings = dict;
|
_strings = dict;
|
||||||
|
lock (_reportedMisses)
|
||||||
|
_reportedMisses.Clear();
|
||||||
CurrentLangCode = code;
|
CurrentLangCode = code;
|
||||||
CurrentLanguage = name;
|
CurrentLanguage = name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -391,7 +391,10 @@ public partial class Scenarios : UserControl
|
|||||||
{
|
{
|
||||||
Process.Start(new ProcessStartInfo(full) { UseShellExecute = true });
|
Process.Start(new ProcessStartInfo(full) { UseShellExecute = true });
|
||||||
}
|
}
|
||||||
catch { }
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
StarterNG.Infrastructure.Diagnostics.Log($"opening {full}", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RebuildAfterLanguageChange()
|
public void RebuildAfterLanguageChange()
|
||||||
|
|||||||
@@ -210,4 +210,3 @@ internal sealed class TextureRow
|
|||||||
System.Globalization.DateTimeStyles.None, out var rev) ? rev : null;
|
System.Globalization.DateTimeStyles.None, out var rev) ? rev : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user