fix: Update error handling in ServiceBasedApp and main to fallback to console logging when logger is unavailable

This commit is contained in:
2026-01-04 14:54:43 +00:00
parent 7b549804f9
commit a4802179e0
2 changed files with 11 additions and 5 deletions

View File

@@ -332,11 +332,12 @@ int main(int argc, char** argv) {
throw std::runtime_error("Unable to determine platform config directory");
}
}
sdl3cpp::app::ServiceBasedApp app(options.runtimeConfig.scriptPath);
app.Run();
} catch (const std::runtime_error& e) {
std::string errorMsg = e.what();
sdl3cpp::logging::Logger::GetInstance().Error("Runtime error: " + errorMsg);
// For early errors before app is created, we can't use service logger
// Fall back to console output
std::cerr << "Runtime error: " << errorMsg << std::endl;
// Check if this is a timeout/hang error - show simpler message for these
bool isTimeoutError = errorMsg.find("timeout") != std::string::npos ||
@@ -362,7 +363,8 @@ int main(int argc, char** argv) {
}
return EXIT_FAILURE;
} catch (const std::exception& e) {
sdl3cpp::logging::Logger::GetInstance().Error("Exception: " + std::string(e.what()));
// For early errors before app is created, we can't use service logger
std::cerr << "Exception: " << e.what() << std::endl;
SDL_ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR,
"Application Error",