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

Added error-handling for piping #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

williFiebranz
Copy link

Changed default behavior of error handling in two ways:

  1. fail_with default is now try(stop(e))
  2. if class(.value) == ‚try-error‘ return .value immediately

Changed default behavior of error handling in two ways:
1. fail_with default is now try(stop(e))
2. if class(.value) == ‚try-error‘ return .value immediately
@smbache
Copy link
Owner

smbache commented Jun 12, 2015

Problem is that ensure would no longer "ensure" by default:

get_important_message %>% # suppose this fails, maybe the result is say, `FALSE`
  ensure_that(is.character) %>% 
  send_message

Since try-errors actually pass is.character you could end up sending the error in this example.
Even though this is a pseudo-example it shows that ensure did not ensure that get_important_message got a character message before allowing control to be handed over to send_message, which may send an error rather than the message.

@smbache
Copy link
Owner

smbache commented Jun 12, 2015

Also, in your example, why not just have both conditions in one call to ensure rather than chaining them. The latter option is really meant to be used when you don't want to check this before knowing that the previous call passed.

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

Successfully merging this pull request may close these issues.

None yet

2 participants