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
Use Log.InGame for less important codes when in InDev and ignore the …
…less important codes in release. The idea here is that popups are only displayed for status codes that would be standalone and important, entirely disrupting the user experience
  • Loading branch information
OhmV-IR committed Mar 20, 2024
commit 2baf5703f7c2edcc1da87b11d29a7ab4316aa6d8
6 changes: 3 additions & 3 deletions Nitrox.Test/Model/StatusCodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public class StatusCodeTests
public void ThrowStatusCodesDisplay()
{
var statusCodeNames = Enum.GetNames(typeof(StatusCode));
// Display one of every status code once non-fatally, should display all of them once and show "test passed"
// Display one of every status code once non-fatally, should display all of the popup ones once, and the ingame log ones will be silent, then show "test passed"
for (int i = 0; i < statusCodeNames.Length; i++)
{
DisplayStatusCode((StatusCode)Enum.Parse(typeof(StatusCode), statusCodeNames[i]), statusCodeNames[i] + " Testing exception");
}
}
[TestMethod]
public void ThrowStatusCodesLongExceptionDisplay()
public void ThrowStatusCodeLongExceptionDisplay()
{

// Test if the text will wrap or if the messageBox will expand to accomodate for a long exception message
Expand All @@ -28,7 +28,7 @@ public void ThrowStatusCodesLongExceptionDisplay()
[TestMethod]
public void ThrowStatusCodesPrint()
{
// Display one of every status code once non-fatally, should display all of them once and show "test passed"
// Display one of every status code once non-fatally, should print them all which will be visible in the results and show "test passed"
var statusCodeNames = Enum.GetNames(typeof(StatusCode));
for (int i = 0; i < statusCodeNames.Length; i++)
{
Expand Down
25 changes: 22 additions & 3 deletions NitroxModel/DisplayStatusCodes.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Windows.Forms;
using System;
using System.Diagnostics;
using NitroxModel.Helper;
using System.Diagnostics.Eventing.Reader;
namespace NitroxModel
{
public class DisplayStatusCodes
Expand Down Expand Up @@ -35,17 +37,34 @@ public enum StatusCode
// Display a statusCode to the user(should be for statusCodes that are due to an error from the client)
public static void DisplayStatusCode(StatusCode statusCode, string exception)
{
// Display a popup message box using CustomMessageBox.cs which has most of the buttons and strings filled in with a placeholder for the statusCode
// Only make a popup message if the code is important, and most likely standalone
if (statusCode == StatusCode.PORT_NOT_LISTENING || statusCode == StatusCode.PRIVILEGES_ERR || statusCode == StatusCode.FILE_SYSTEM_ERR || statusCode == StatusCode.DEAD_PIRATES_TELL_NO_TALES || statusCode == StatusCode.DEPENDENCY_FAIL
|| statusCode == StatusCode.VERSION_MISMATCH || statusCode == StatusCode.INVALID_INSTALL || statusCode == StatusCode.STORE_NOT_RUNNING || statusCode == StatusCode.FIREWALL_MOD_FAIL || statusCode == StatusCode.INTERNET_CONNECTION_FAIL_LAUNCHER)
{
CustomMessageBox customMessage = new(statusCode, exception);
customMessage.StartPosition = FormStartPosition.CenterParent;
customMessage.ShowDialog();
}
else if (NitroxEnvironment.ReleasePhase == "InDev")
{
// Only log on in game on InDev sessions, average player cannot interpret the message and it would simply be extra clutter
Log.InGame("Error " + statusCode.ToString("D") + ": " + exception);
}
}

// Print the statusCode to the server console(only for statusCodes that are due to an error from the server)
public static void PrintStatusCode(StatusCode statusCode, string exception)
{
// Log the status code to server console along with the exception message
Log.Error(string.Concat("Status code = ", statusCode.ToString("D"), " <- Look up this code on the nitrox website for more information about this error." + "Exception message: " + exception));
// If the status code is important, log it in the server console
if (statusCode == StatusCode.PORT_NOT_LISTENING || statusCode == StatusCode.PRIVILEGES_ERR || statusCode == StatusCode.FILE_SYSTEM_ERR || statusCode == StatusCode.DEAD_PIRATES_TELL_NO_TALES || statusCode == StatusCode.DEPENDENCY_FAIL
|| statusCode == StatusCode.VERSION_MISMATCH || statusCode == StatusCode.INVALID_INSTALL || statusCode == StatusCode.STORE_NOT_RUNNING || statusCode == StatusCode.FIREWALL_MOD_FAIL || statusCode == StatusCode.INTERNET_CONNECTION_FAIL_LAUNCHER)
{
Log.Error(string.Concat("Status code = ", statusCode.ToString("D"), " <- Look up this code on the nitrox website for more information about this error." + "Exception message: " + exception));
}
else if (NitroxEnvironment.ReleasePhase == "InDev")
{
Log.Error(string.Concat("Status code = ", statusCode.ToString("D"), " <- Look up this code on the nitrox website for more information about this error." + "Exception message: " + exception));
}
}
}
}