Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error rather than warning if download fails #7

Open
richfitz opened this issue May 3, 2018 · 4 comments
Open

Error rather than warning if download fails #7

richfitz opened this issue May 3, 2018 · 4 comments

Comments

@richfitz
Copy link
Member

richfitz commented May 3, 2018

ssh::scp_download just warns if upload fails rather than errors - can this be turned into an error (even if it's an option that one has to set)?

@jeroen
Copy link
Member

jeroen commented May 27, 2018

Yeah I'm not entirely sure yet how to deal with this. If you are downloading many files, and one fails, should the entire operation be aborted? What about files that you already downloaded?

@richfitz
Copy link
Member Author

My thoughts:

I personally really dislike warnings in R - they're easily lost and don't get printed at a useful time. If it's informational and requires no user action I prefer message and if it's likely something terrible happened then I prefer errors (same idea as https://dave.cheney.net/2015/11/05/lets-talk-about-logging) but I recognise that's just a personal view.

How about return a logical vector TRUE/FALSE for success and include a must_work argument (so that if all files must be transferred successfully then it's easy to throw).

Because of the manipulation of global state you can't make the whole thing atomic (all work or none work) and scp itself doesn't try.

@jxu
Copy link
Contributor

jxu commented Jun 28, 2019

What about

options(warn=2)

@yaotianran
Copy link

With tryCatch one can easily capture errors or warnings

exception = tryCatch(
      {
       # something you want to do
      },
      error = function(e) e,
      warning = function(w) w
   )
if (inherits(exception, 'warning')) {
   stop('An error occured.')
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants