Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions R/DataMart.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ QFileExists <- function(filename, show.warning = TRUE, company.token = NA, docum
if (is.null(res$status_code) || res$status_code != 200)
{
if (show.warning)
warning("File not found.")
warning("This file may not exist in the Displayr Cloud Drive or you may not have permission to access it.")
return (FALSE)
}
else
Expand Down Expand Up @@ -92,7 +92,7 @@ QFileOpen <- function(filename, open = "r", blocking = TRUE,
if (inherits(con, "condition")) {
problem <- conditionMessage(con)
if (problem == "HTTP error 404.")
problem <- "file not found"
problem <- "This file may not exist in the Displayr Cloud Drive or you may not have permission to access it."
stopBadRequest(con, paste0("Could not open ", filename, ": ", problem))
}

Expand Down Expand Up @@ -224,10 +224,7 @@ QLoadData <- function(filename, company.token = NA, document.token = NA,...)
else if (res$status_code != 200)
{
if (!QFileExists(filename, show.warning = FALSE))
StopForUserError(
"The data file '", filename, "' does not exist in the Displayr cloud drive. ",
"Ensure that the data file is in the Displayr cloud drive and its name has been correctly specified."
)
StopForUserError("This file '", filename, "' may not exist in the Displayr Cloud Drive or you may not have permission to access it.")
else
stopBadRequest(res, msg)
}
Expand Down Expand Up @@ -345,14 +342,12 @@ QSaveData <- function(object, filename, compression.file.size.threshold = NULL,
has.errored <- inherits(res, "try-error")

if (!has.errored && res$status_code == 413) # 413 comes from IIS when we violate its web.config limits
{
stopBadRequest(res, "Could not write to Displayr Cloud Drive. Data to write is too large.")
}
else if (!has.errored && res$status_code == 422)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be changed on the Displayr side as well.

else if (!has.errored && res$status_code == 404)
{
stop("QSaveData has encountered an unknown error. ",
"422: The file could not properly be saved. ",
"The likely cause was an incorrect path preceding the filename.")
"404: The file could not properly be saved. ",
"The likely cause was an incorrect path preceding the filename, or insufficient access to the file path.")
}
else if (has.errored || res$status_code != 200)
{
Expand Down Expand Up @@ -407,7 +402,7 @@ QDeleteFiles <- function(filenames, company.token = getCompanySecret(), document
if (inherits(res, "try-error") || res$status_code != 200)
{
warning("Encountered an error deleting the following files: ", filenames.string)
stopBadRequest(res, paste0("Could not delete files: ", filenames.string))
stopBadRequest(res, paste0("Could not delete files: ", filenames.string, ". These files may not exist in the Displayr Cloud Drive or you may not have permission to access them."))
}
msg <- paste0("Successfully deleted files: ", filenames.string)
message(msg)
Expand Down
Loading