Skip to content

Commit

Permalink
show curl error message when error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed May 15, 2012
1 parent 7a4d888 commit 3dfbcb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
16 changes: 10 additions & 6 deletions src/cpp/session/modules/SessionRPubs.R
Expand Up @@ -332,16 +332,20 @@ rpubsUpload <- function(title,
"--header", paste("Content-Length:", fileLength, sep=""),
extraHeaders,
"--header", "Expect:",
"-s",
"--silent",
"--show-error",
"-o", shQuote(outputFile),
paste("https://rpubs.com", path, sep=""))

system(command)
result <- system(command)

fileConn <- file(outputFile, "rb")
on.exit(close(fileConn))

readResponse(fileConn)
if (result == 0) {
fileConn <- file(outputFile, "rb")
on.exit(close(fileConn))
readResponse(fileConn)
} else {
stop(paste("Upload failed (curl error", result, "occurred)"))
}
}

# determine the upload function, scheme, and port
Expand Down
11 changes: 0 additions & 11 deletions src/cpp/session/modules/SessionRPubs.cpp
Expand Up @@ -11,17 +11,6 @@
*
*/

// TODO: is there a way to get a better error diagnostic out of a
// network failure in calling system(curl) -- we get a file
// output error right now, any way for R to capture standard error?

// NOTE: may be able to do this with a combination of passing --show-error
// to curl and then capturing the output from R using:
// output <- suppressWarnings(system(command, intern = TRUE))
// then if the output file doesn't exist we return the output as
// an error

// TODO: should we prefer RCurl due to the above error reporting issue?
// TODO: notification of public publishing w/ "don't show again"

// TODO: progress dialog for preparing to publish (including cancel)
Expand Down

0 comments on commit 3dfbcb7

Please sign in to comment.