mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Handle write exception for log handler (#2135)
This commit is contained in:
parent
6871d5cd7d
commit
b7e3b04f62
@ -182,7 +182,7 @@ namespace Bloxstrap
|
|||||||
{
|
{
|
||||||
Logger.Initialize(LaunchSettings.IsUninstall);
|
Logger.Initialize(LaunchSettings.IsUninstall);
|
||||||
|
|
||||||
if (!Logger.Initialized)
|
if (!Logger.Initialized && !Logger.NoWriteMode)
|
||||||
{
|
{
|
||||||
Logger.WriteLine(LOG_IDENT, "Possible duplicate launch detected, terminating.");
|
Logger.WriteLine(LOG_IDENT, "Possible duplicate launch detected, terminating.");
|
||||||
Terminate();
|
Terminate();
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
public readonly List<string> Backlog = new();
|
public readonly List<string> Backlog = new();
|
||||||
public bool Initialized = false;
|
public bool Initialized = false;
|
||||||
|
public bool NoWriteMode = false;
|
||||||
public string? FileLocation;
|
public string? FileLocation;
|
||||||
|
|
||||||
public void Initialize(bool useTempDir = false)
|
public void Initialize(bool useTempDir = false)
|
||||||
@ -45,6 +46,23 @@
|
|||||||
WriteLine(LOG_IDENT, "Failed to initialize because log file already exists");
|
WriteLine(LOG_IDENT, "Failed to initialize because log file already exists");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
if (NoWriteMode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
WriteLine(LOG_IDENT, $"Failed to initialize because Bloxstrap cannot write to {directory}");
|
||||||
|
|
||||||
|
Frontend.ShowMessageBox(
|
||||||
|
String.Format(Resources.Strings.Logger_NoWriteMode, directory),
|
||||||
|
System.Windows.MessageBoxImage.Warning,
|
||||||
|
System.Windows.MessageBoxButton.OK
|
||||||
|
);
|
||||||
|
|
||||||
|
NoWriteMode = true;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
|
9
Bloxstrap/Resources/Strings.Designer.cs
generated
9
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -1317,6 +1317,15 @@ namespace Bloxstrap.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to No log file will be written for this launch because Bloxstrap is unable to write to the folder at '{0}'.
|
||||||
|
/// </summary>
|
||||||
|
public static string Logger_NoWriteMode {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Logger.NoWriteMode", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Contributors.
|
/// Looks up a localized string similar to Contributors.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1079,4 +1079,7 @@ Selecting 'No' will ignore this warning and continue installation.</value>
|
|||||||
<data name="Menu.FastFlagEditor.InvalidNumberValue" xml:space="preserve">
|
<data name="Menu.FastFlagEditor.InvalidNumberValue" xml:space="preserve">
|
||||||
<value>The entry for '{0}' is not valid as the value must be a number</value>
|
<value>The entry for '{0}' is not valid as the value must be a number</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Logger.NoWriteMode" xml:space="preserve">
|
||||||
|
<value>No log file will be written for this launch because Bloxstrap is unable to write to the folder at '{0}'</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user