| 29 | } |
| 30 | |
| 31 | httplib::Result executeRequest(std::function<httplib::Result()> const& func, bool withRetry = true) |
| 32 | { |
| 33 | auto attempt = 0; |
| 34 | while (true) { |
| 35 | auto result = func(); |
| 36 | if (result) { |
| 37 | return result; |
| 38 | } |
| 39 | if (++attempt == 5 || !withRetry) { |
| 40 | throw std::runtime_error("Error connecting to the server."); |
| 41 | } |
| 42 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | void logNetworkError() |
| 47 | { |
no outgoing calls
no test coverage detected