Skip to content

Commit

Permalink
remove try block
Browse files Browse the repository at this point in the history
* remove try block and trap for explicit entry earlier
  • Loading branch information
abraunegg committed Jun 28, 2019
1 parent 8449b45 commit 7cf73a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -2058,7 +2058,6 @@ final class SyncEngine
writeln("");
try {
response = session.upload(path, parent.driveId, parent.id, baseName(path));
writeln(" done.");
} catch (OneDriveException e) {
// error uploading file
log.vlog("Upload failed with OneDriveException: ", e.msg);
Expand All @@ -2067,17 +2066,22 @@ final class SyncEngine
log.vlog("Upload failed with File Exception: ", e.msg);
return;
}
writeln(" done.");
}
} else {
// OneDrive Business Account - always use a session to upload
writeln("");
try {
response = session.upload(path, parent.driveId, parent.id, baseName(path));
writeln(" done.");
} catch (OneDriveException e) {
// error uploading file
log.vlog("Upload failed with OneDriveException: ", e.msg);
return;
} catch (FileException e) {
log.vlog("Upload failed with File Exception: ", e.msg);
return;
}
writeln(" done.");
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/upload.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ struct UploadSession
])
];

try {
// Try to create the upload session for this file
session = onedrive.createUploadSession(parentDriveId, parentId, filename, eTag, fileSystemInfo);
// Try to create the upload session for this file
session = onedrive.createUploadSession(parentDriveId, parentId, filename, eTag, fileSystemInfo);

if ("uploadUrl" in session){
session["localPath"] = localPath;
save();
return upload();
} catch (OneDriveException e) {
} else {
// there was an error
log.vlog("Create file upload session failed ... skipping file upload");
// return upload() will return a JSONValue response, create an empty JSONValue response to return
Expand Down

0 comments on commit 7cf73a2

Please sign in to comment.