Skip to content

Commit

Permalink
Catch exception in Nsyshid on Windows and log it in logDebug
Browse files Browse the repository at this point in the history
This keeps Cemu from crashing when nsyshid's logging encounters an error on Windows and prints the type of exception encountered to the log.
  • Loading branch information
Squall-Leonhart authored Sep 25, 2023
1 parent 638c401 commit 21971f3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,17 @@ namespace nsyshid::backend::windows
{
sprintf(debugOutput + i * 3, "%02x ", data[i]);
}
fmt::print("{} Data: {}\n", prefix, debugOutput);
cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput);

try
{
fmt::print("{} Data: {}\n", prefix, debugOutput);
cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput);
} catch (const std::exception& e)
{
fmt::print("Error while logging: {}\n", e.what());
cemuLog_logDebug(LogType::Force, "Error while logging: {}", e.what());

}
}
} // namespace nsyshid::backend::windows

Expand Down

0 comments on commit 21971f3

Please sign in to comment.