Handle legitimate exception for "expected" failures

This commit is contained in:
Kamil Trzciński 2022-12-18 09:29:25 +01:00
parent ec0a84283b
commit 8cc45ed6b4
4 changed files with 24 additions and 2 deletions

View file

@ -105,5 +105,13 @@ namespace CommonHelpers
scope.SetTag("type", type);
});
}
public static void DebugException(String type, Exception e)
{
}
public static void DebugException(String type, Object? name, Exception e)
{
}
}
}

View file

@ -120,7 +120,11 @@ namespace SteamController.Devices
}
catch (Exception e)
{
TraceException("STEAM", "Update", e);
// Steam have disconnected device, which triggered exception
if (e.Message == "Could not send report to hid device. Error: -1")
DebugException("STEAM", "Update", e);
else
TraceException("STEAM", "Update", e);
Fail();
}
}

View file

@ -96,7 +96,11 @@ namespace SteamController.Devices
catch (System.ComponentModel.Win32Exception e)
{
// This is expected exception (as sometimes device will fail to connect)
TraceException("X360", "ConnectExpected", e);
// ERROR_SUCCESS, which likely means COM did not succeed
if (e.NativeErrorCode == 0)
DebugException("X360", "ConnectExpected", e);
else
TraceException("X360", "ConnectExpected", e);
Fail();
return;
}

View file

@ -340,6 +340,12 @@ namespace SteamController.Helpers
File.Copy(configPath + ".orig", configPath, true);
return true;
}
catch (FileNotFoundException e)
{
// File was not found (which is valid as it might be before first start of the application)
Log.DebugException("STEAM", e);
return false;
}
catch (DirectoryNotFoundException)
{
// Steam was installed, but got removed