statusweather: Catch all exceptions.

This commit is contained in:
tastytea 2021-08-23 18:35:25 +02:00
parent 8ef801d1df
commit 0977bc557d
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 20 additions and 9 deletions

View File

@ -23,6 +23,7 @@
#include <atomic>
#include <chrono>
#include <cstdint>
#include <exception>
#include <fstream>
#include <functional>
#include <future>
@ -193,19 +194,29 @@ void update(std::atomic<bool> &cancelled)
int main()
{
// TODO: Implement clean shutdown.
std::atomic<bool> cancelled{false};
auto future{std::async(std::launch::async, update, std::ref(cancelled))};
std::string line;
while (std::getline(std::cin, line)) // Button click is sent to stdin.
try
{
if (line == "1") // Left mouse button.
// TODO: Implement clean shutdown.
std::atomic<bool> cancelled{false};
auto future{
std::async(std::launch::async, update, std::ref(cancelled))};
std::string line;
while (std::getline(std::cin, line)) // Button click is sent to stdin.
{
if (fetch_weather())
if (line == "1") // Left mouse button.
{
print_weather();
if (fetch_weather())
{
print_weather();
}
}
}
}
catch (std::exception &e)
{
std::cout << R"(<span color="red">)" << e.what() << "</span>"
<< std::endl;
return 33;
}
}