Skip to content

Commit

Permalink
Improve error routine
Browse files Browse the repository at this point in the history
This way we avoid slow reflection-based Enum.IsDefined() while covering out-of-range values.
  • Loading branch information
JustArchi committed Dec 1, 2017
1 parent d07d824 commit 97c1a7a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ArchiSteamFarm/ArchiHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,21 @@ internal NotificationsCallback(JobID jobID, CMsgClientUserNotifications msg) {
foreach (CMsgClientUserNotifications.Notification notification in msg.notifications) {
ENotification type = (ENotification) notification.user_notification_type;

if (type == ENotification.Unknown) {
ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(type), type));
continue;
switch (type) {
case ENotification.AccountAlerts:
case ENotification.Chat:
case ENotification.Comments:
case ENotification.GameTurns:
case ENotification.Gifts:
case ENotification.HelpRequestReplies:
case ENotification.Invites:
case ENotification.Items:
case ENotification.ModeratorMessages:
case ENotification.Trading:
break;
default:
ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(type), type));
continue;
}

Notifications[type] = notification.count;
Expand Down

0 comments on commit 97c1a7a

Please sign in to comment.