test for curl exception when checking online status (#117)

* Check for a curl exception when checking the online status of the client at startup
This commit is contained in:
abraunegg 2018-08-14 07:21:11 +10:00 committed by GitHub
parent 6a6e0079af
commit 6a5ab5607a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ import core.stdc.stdlib: EXIT_SUCCESS, EXIT_FAILURE;
import core.memory, core.time, core.thread;
import std.getopt, std.file, std.path, std.process, std.stdio, std.conv;
import config, itemdb, monitor, onedrive, selective, sync, util;
import std.net.curl: CurlException;
static import log;
int main(string[] args)
@ -62,7 +63,9 @@ int main(string[] args)
bool skipSymlinks;
// Add option for no remote delete
bool noRemoteDelete;
// Are we able to reach the OneDrive Service
bool online = false;
try {
auto opt = getopt(
args,
@ -145,11 +148,13 @@ int main(string[] args)
}
log.vlog("Initializing the OneDrive API ...");
bool online = testNetwork();
if (!online && !monitor) {
log.error("No network connection");
try {
online = testNetwork();
} catch (CurlException e) {
// No network connection to OneDrive Service
log.error("No network connection to Microsoft OneDrive Service");
return EXIT_FAILURE;
}
}
// Initialize OneDrive, check for authorization
auto onedrive = new OneDriveApi(cfg, debugHttp);