From fb0a5f0796b919690e635c064634fc74627e409e Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sun, 23 Jul 2023 10:13:03 +1000 Subject: [PATCH] Fix unhandled exception when authurl path is non-existent (#2456) * Catch an unhandled exception when the user sets the authurl file to a location that cannot be accessed --- src/onedrive.d | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/onedrive.d b/src/onedrive.d index b333d849..29d33a46 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -586,9 +586,19 @@ final class OneDriveApi string[] authFiles = authFilesString.split(":"); string authUrl = authFiles[0]; string responseUrl = authFiles[1]; - auto authUrlFile = File(authUrl, "w"); - authUrlFile.write(url); - authUrlFile.close(); + + try { + // Try and write out the auth URL to the nominated file + auto authUrlFile = File(authUrl, "w"); + authUrlFile.write(url); + authUrlFile.close(); + } catch (std.exception.ErrnoException e) { + // There was a file system error + // display the error message + displayFileSystemErrorMessage(e.msg, getFunctionName!({})); + return false; + } + while (!exists(responseUrl)) { Thread.sleep(dur!("msecs")(100)); }