-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Update SteamStatisticFactory.cs #27
base: main
Are you sure you want to change the base?
Conversation
Changes to log unhandled 'stat' before throwing exception to figure out what 'stat' is causing the issue before crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the formatting (indentation) and at least add the logger instead of the Console.WriteLine since there is no console. Logging it as error will add write it to the normal log file as well as the error log file.
@@ -17,44 +17,46 @@ public static class SteamStatisticFactory | |||
/// </returns> | |||
/// <exception cref="ArgumentNullException">Occurs when the <paramref name="client"/>, <paramref name="stat"/>, or the <paramref name="stat"/> <see cref="StatInfoBase.Id"/> is <see langword="null"/> or empty.</exception> | |||
/// <exception cref="ArgumentOutOfRangeException">Occurs when an unkown <paramref name="stat"/> type is supplied.</exception> | |||
public static SteamStatisticBase CreateStat(Client client, StatInfoBase stat) | |||
public static SteamStatisticBase CreateStat(Client client, StatInfoBase stat) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you fix this indentation, please?
} | ||
default: | ||
// Log the type of the unhandled stat | ||
Console.WriteLine($"Unhandled stat type: {stat.GetType()} with ID: {stat.Id}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to log.Error()
. I don't think this class has an ILogger
yet, but you can add it at the top of the class. If you search for LogManager
you'll find others.
private static readonly ILog log = LogManager.GetLogger(nameof(SteamStatisticFactory));
You'll need this namespace at the top too.
using log4net;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That GetType()
is just the inherited .NET object
's GetType
method. It will just say it's a StatInfoBase
. Logging the Id
is good, we can at least look it up with that but IDs aren't unique across all apps. I would probably do this:
var sb = new StringBuilder();
sb.Append($"Unable to create user stat '{stat.Id}' in {client.AppId}. ");
sb.Append($"Stat '{stat.Id}' is type '{stat.UserStatType}' ({stat.UserStatType:D})");
// log the permissions flags if present
if (!string.IsNullOrEmpty(stat.Extra))
{
sb.Append($" with permissions '{stat.Extra}'");
}
sb.Append(".");
log.Error(sb);
That should be enough info to figure out what's going on. I am guessing it's either a protected stat or something weird. I need to buy a game that has the issue so I can try and
Changes to log unhandled 'stat' before throwing exception to figure out what 'stat' is causing the issue before crash.
Resolves issues where game titles including Unicode characters can cause SAM to crash.