Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding popup messages for errors with status codes alongside the exception message #2116

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
59924de
Initial commit to open PR
OhmV-IR Jan 16, 2024
2bc36cb
Added enum for status codes and function to print them
OhmV-IR Jan 17, 2024
a4afd49
Use integer enum overload
OhmV-IR Jan 18, 2024
3651990
Added project reference and status codes for NitroxConfig.cs
OhmV-IR Jan 26, 2024
cd4392c
Added error messages in a popup for nitroxModel
OhmV-IR Feb 4, 2024
4aaf86d
fix missing import statements so the solution can build
OhmV-IR Feb 4, 2024
6fb3a87
added a better messageBox dialog to display status code errors
OhmV-IR Feb 4, 2024
7488213
moved display status code enum out of nitrox server into new files in…
OhmV-IR Feb 5, 2024
6b23109
MORE FUNCTION CALLS
OhmV-IR Feb 6, 2024
60e673a
added more descriptive names for statusCodes in the files and moved s…
OhmV-IR Feb 12, 2024
e76df2f
Finished adding statusCode calls to NitroxClient
OhmV-IR Feb 12, 2024
388fd96
Check if nitroxLauncher is in a oneDrive folder implementation
OhmV-IR Feb 14, 2024
741099a
Added fatal flag to statusCode function calls
OhmV-IR Feb 20, 2024
ca8a205
Added exception message to StatusCode messageBox
OhmV-IR Feb 20, 2024
051f09a
Added exception messages to PrintStatusCode <- server status codes fu…
OhmV-IR Feb 20, 2024
df46194
Merge pull request #1 from OhmV-IR/inDev
OhmV-IR Feb 20, 2024
2a03491
removed unused isPirate bool in CustomMessagebox.cs
OhmV-IR Feb 20, 2024
9f3e552
Added test fail case for FatalStatusCodes and removed success status …
OhmV-IR Feb 20, 2024
219ef4e
Added text wrapping so that the exception message does not exceed the…
OhmV-IR Feb 21, 2024
cb86f5c
Change statusCode enum to use HTTP status codes and condense redundan…
OhmV-IR Feb 22, 2024
5ca499c
Changed enum names to follow upper snake case convention
OhmV-IR Feb 22, 2024
4a2bf7c
Changed SYNC_FAIL to use a different code than MISSING_FEATURE
OhmV-IR Feb 22, 2024
973015b
Fixed a typo that caused build errors
OhmV-IR Feb 22, 2024
a23a8ed
Added some more comments and finished unit testing, just need to play…
OhmV-IR Feb 24, 2024
f778fe1
Change enum names, use HTTP status codes, unit tests, should be ready…
OhmV-IR Feb 24, 2024
81cce0e
Client disconnects are never recognized as fatal, even if they happen…
OhmV-IR Feb 24, 2024
fc0e7dd
Merge branch 'prod-status-codes' into polishing-status-codes
OhmV-IR Feb 27, 2024
3ba4bbf
Added missing using statement
OhmV-IR Feb 27, 2024
c0b9278
Removed unneeded comments
OhmV-IR Mar 12, 2024
ace18b4
removed a useless comment
OhmV-IR Mar 17, 2024
0b542eb
Removed some usings and fixed using assemblies that had not yet been …
OhmV-IR Mar 18, 2024
1b2cb10
Merge branch 'polishing-status-codes' into master
OhmV-IR Mar 19, 2024
57b8ea2
Merge pull request #6 from OhmV-IR/master
OhmV-IR Mar 19, 2024
0137f03
Removed fatal program closes(its just bad design to end execution so …
OhmV-IR Mar 20, 2024
2baf570
Use Log.InGame for less important codes when in InDev and ignore the …
OhmV-IR Mar 20, 2024
505da81
Fixed creating release builds
OhmV-IR Mar 20, 2024
20b28f7
Changed ingame log string + removed unneeded reference in NitroxLauncher
OhmV-IR Mar 20, 2024
5a1f315
Added more function calls
OhmV-IR Mar 24, 2024
5db1930
Small fixes
OhmV-IR Mar 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added project reference and status codes for NitroxConfig.cs
  • Loading branch information
OhmV-IR committed Jan 26, 2024
commit 36519907a25b1f79b0cab47b088fd0c7649530c3
3 changes: 3 additions & 0 deletions NitroxModel/NitroxModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<Reference Include="LZ4">
<HintPath>..\Nitrox.Assets.Subnautica\LZ4.dll</HintPath>
</Reference>
<Reference Include="NitroxServer">
<HintPath>..\NitroxServer\bin\Debug\NitroxServer.dll</HintPath>
</Reference>
<Reference Include="protobuf-net">
<HintPath>..\Nitrox.Assets.Subnautica\protobuf-net.dll</HintPath>
</Reference>
Expand Down
8 changes: 6 additions & 2 deletions NitroxModel/Serialization/NitroxConfig.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

using static NitroxServer.Server;
// using static NitroxServer.Server;
namespace NitroxModel.Serialization
{
public abstract class NitroxConfig<T> where T : NitroxConfig<T>, new()
Expand Down Expand Up @@ -76,6 +77,7 @@ public void Deserialize(string saveDir)
else
{
Log.Error($"Incorrect format detected on line {lineNum} in {Path.GetFullPath(Path.Combine(saveDir, FileName))}:{Environment.NewLine}{readLine}");
PrintStatusCode(StatusCode.four);
}
}

Expand Down Expand Up @@ -134,6 +136,7 @@ public void Serialize(string saveDir)
catch (UnauthorizedAccessException)
{
Log.Error($"Config file {FileName} exists but is a hidden file and cannot be modified, config file will not be updated. Please make file accessible");
PrintStatusCode(StatusCode.five);
}
}
}
Expand Down Expand Up @@ -167,6 +170,7 @@ public UpdateDiposable Update(string saveDir)
catch (ArgumentException e)
{
Log.Error(e, $"Type {type.FullName} has properties that require case-sensitivity to be unique which is unsuitable for .properties format.");
PrintStatusCode(StatusCode.four);
throw;
}
}
Expand Down
20 changes: 1 addition & 19 deletions NitroxServer-Subnautica/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using NitroxModel.Platforms.OS.Shared;
using NitroxServer;
using NitroxServer.ConsoleCommands.Processor;
using static NitroxServer.Server;

namespace NitroxServer_Subnautica;

Expand All @@ -30,25 +31,6 @@ public class Program
private static Lazy<string> gameInstallDir;
private static readonly CircularBuffer<string> inputHistory = new(1000);
private static int currentHistoryIndex;
public enum StatusCode
{
zero,
one,
two,
three
}
public static void PrintStatusCode(StatusCode statusCode)
{
if (statusCode != StatusCode.zero)
{
// ToString("D") prints the integer value of the statusCode enum
Log.Error(string.Concat("Status code = ", statusCode.ToString("D"), " <- Look up this code on the nitrox website for more information about this error"));
}
else
{
Log.Info(string.Concat("Status code = ", statusCode.ToString("D")));
}
}
private static async Task Main(string[] args)
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;
Expand Down
8 changes: 4 additions & 4 deletions NitroxServer/ConsoleCommands/ConfigCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
Expand All @@ -8,7 +8,7 @@
using NitroxServer.ConsoleCommands.Abstract;
using NitroxServer.Serialization;
using NitroxServer.Serialization.World;

using static NitroxServer.Server;
namespace NitroxServer.ConsoleCommands
{
internal class ConfigCommand : Command
Expand All @@ -28,7 +28,6 @@ protected override void Execute(CallArgs args)
Log.Warn("Waiting on previous config command to close the configuration file.");
return;
}

// Save config file if it doesn't exist yet.
string saveDir = Path.Combine(WorldManager.SavesFolderDir, serverConfig.SaveName);
string configFile = Path.Combine(saveDir, serverConfig.FileName);
Expand All @@ -55,6 +54,7 @@ protected override void Execute(CallArgs args)
#if DEBUG
if (t.Exception != null)
{
PrintStatusCode(StatusCode.four);
throw t.Exception;
}
#endif
Expand All @@ -63,7 +63,7 @@ protected override void Execute(CallArgs args)

private async Task StartWithDefaultProgram(string fileToOpen)
{
using Process process = FileSystem.Instance.OpenOrExecuteFile(fileToOpen);
using Process process = FileSystem.Instance.OpenOrExecuteFile(fileToOpen); // SCARY CODE, could be used for RCE or privilege escalation
process.WaitForExit();
try
{
Expand Down
21 changes: 21 additions & 0 deletions NitroxServer/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ public class Server
public bool IsSaving { get; private set; }

public int Port => serverConfig?.ServerPort ?? -1;
public enum StatusCode
{
zero,
one,
two,
three,
four,
five
}
public static void PrintStatusCode(StatusCode statusCode)
{
if (statusCode != StatusCode.zero)
{
// ToString("D") prints the integer value of the statusCode enum
Log.Error(string.Concat("Status code = ", statusCode.ToString("D"), " <- Look up this code on the nitrox website for more information about this error"));
}
else
{
Log.Info(string.Concat("Status code = ", statusCode.ToString("D")));
}
}

public Server(WorldPersistence worldPersistence, World world, ServerConfig serverConfig, Communication.NitroxServer server, WorldEntityManager worldEntityManager, EntityRegistry entityRegistry)
{
Expand Down