Skip to content

Fix empty exception messages, lost log lines, and unbounded curl requests in TitleHelper - #12

Open
Ashnar2602 wants to merge 3 commits into
wiredopposite:masterfrom
Ashnar2602:fix/error-message-and-network-timeouts
Open

Fix empty exception messages, lost log lines, and unbounded curl requests in TitleHelper#12
Ashnar2602 wants to merge 3 commits into
wiredopposite:masterfrom
Ashnar2602:fix/error-message-and-network-timeouts

Conversation

@Ashnar2602

Copy link
Copy Markdown

Three small, independent bug fixes found while working with this codebase:

  1. XGDException::what() always returned an empty string. full_message_, the field backing what(), was declared in XGDException.h but never assigned anywhere. log_error() built the real error text into a local variable and only ever sent it to std::cerr, so any catch (const XGDException& e) block that logs e.what() got nothing useful. Fixed by assigning full_message_ in log_error().

  2. XGDLog's destructor bypassed the configured output sink. The destructor wrote straight to std::cerr instead of going through the same path as an explicit << Endl. Several call sites (e.g. the catch blocks in InputHelper.cpp) build a line ending in \n and rely on the destructor to flush it, so those lines never reached whatever Endl is actually wired to (e.g. the GUI's log view). Fixed by routing the destructor through operator<<(Endl).

  3. No timeouts on TitleHelper's curl requests. internet_connected(), set_ogx_titles_online(), unity_query(), and unity_get_title_icon() all call curl_easy_perform() without CURLOPT_CONNECTTIMEOUT/CURLOPT_TIMEOUT. On a slow or unreachable network this can hang indefinitely with no feedback. Added reasonable timeouts to all four.

Each fix is its own commit. No functional/behavioral changes beyond what's described above.

full_message_, the field backing what(), was declared in
XGDException.h but never assigned anywhere. log_error() built the
real error description into a local error_message and only ever
wrote it to std::cerr, so every caller that catches an
XGDException and logs e.what() got an empty string instead of the
actual error detail.

Assign full_message_ in log_error() so what() returns the same
text that gets logged.
The destructor wrote directly to std::cerr instead of routing
through the same flush path as an explicit "<< Endl". Several call
sites in this codebase (e.g. the catch blocks in InputHelper.cpp)
build a log line ending in "\n" rather than an explicit Endl and
rely on the destructor to flush it, so those lines never reached
whatever sink Endl is actually wired to.

Route the destructor through operator<<(Endl) so buffered lines
flush the same way regardless of whether Endl was used explicitly.
internet_connected(), set_ogx_titles_online(), unity_query(), and
unity_get_title_icon() all call curl_easy_perform() without setting
CURLOPT_CONNECTTIMEOUT or CURLOPT_TIMEOUT. On a slow or unreachable
network, any of these calls can block indefinitely, stalling the
whole operation with no indication of what is happening.

Add a connect timeout and an overall timeout to all four requests
(3s/5s for the plain connectivity check, 5s/15s for the others) so
a bad network degrades gracefully instead of hanging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant